Problems
Farmer John has a large farm with
It is guaranteed that the connections between the
How many ways can Farmer John paint the remaining yet-uncolored barns?
Problem credits: Nick Wu
Input
The first line contains two integers
The next
The next
Output
Compute the number of valid ways to paint the remaining barns, modulo
Example
4 1
1 2
1 3
1 4
4 3
8