Problem C
Counting Trees
The Great Lord Pooty likes trees and orders his subordinates
to have them colored black and white. The trees have
A tree has a fixed branching factor
Then, the tree would have its vertices colored either black
or white. After every vertex is colored, all edges connecting vertices of different colors
will be removed, resulting in a forest with many trees. We
call a coloring
The Great Lord would like to ask you: given a tree of
Since the answer can be huge, output it modulo
Of course, one tree is too simple. Since you had boldly
claimed you are the smartest one in His Empire, Lord Pooty, in
all his magnificent glory, demands you to answer for
Input
The input starts with a line containing an integer
Each test case consists of three integers
Output
For each test case, output a line containing the number of
Sample Input 1 | Sample Output 1 |
---|---|
5 3 2 1 7 6 4 5 7 3 4 2 4 1000000000000000000 3233 3233 |
2 40 12 2 8112035382 |