luogu#P7850. 「JZOI-2」干大事
「JZOI-2」干大事
Background
All the members are thinking about organizing an anniversary event, but Xiao Xi only wants to slack off.
So Xiao Xi decided to do something big (go slack off in a big way).
Problem Description
Because Xiao Xi often slacks off, he is very popular among the slackers. Today, Xiao Xi decides to livestream on the most "degenerate" tree in the fish world.
This tree is very "degenerate". It has no root. It has nodes, labeled , and there are edges connecting them. It can change its form: edges may move, disappear, or grow. Let be the number of edges in the tree that satisfy . Then the value of this form is .
Xiao Xi wants to introduce the value of the tree to the salted fish, but he only wants to slack off. So he asks you to compute the sum of the values over all different forms of the tree, and output it modulo .
Multiple test cases.
Input Format
The first line contains a positive integer , the number of test cases.
The next lines each contain a positive integer and a non-negative integer , describing one test case.
Output Format
Output lines. The -th line contains a non-negative integer, the answer for the -th test case.
3
4 2
4 3
5 1
94
228
200
Hint
For of the testdata, , .
For of the testdata, , .
For of the testdata, , .
For of the testdata, , , .
Translated by ChatGPT 5