Problemas
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
Entrada
The first line contains two integers
The next
The next
Salida
Compute the number of valid ways to paint the remaining barns, modulo
Ejemplo
4 1
1 2
1 3
1 4
4 3
8