Tommy has an unrooted tree of
- How many such assignments satisfy these constraints?
- What is the sum of the sum of the weights over all such assignments?
Output the answer modulo
Constraints
Test | Properties | ||
---|---|---|---|
1 | None | ||
2-3 | None | ||
4 | None | ||
5-6 | None | ||
7-8 | For |
||
9-10 | None |
Input Specification
The first line contains two integers
The
The following
Output Specification
On the first line, output the answer for the first question.
On the second line, output the answer for the second question.
Please output exactly two integers, as otherwise your submission could be graded as Presentation Error.
Sample Input
3 1
2 3
3 5
4 6
1 2
1 3
Sample Output
14
78
Comments