#P6561. [SBCOI2020] 人
[SBCOI2020] 人
Description
In her dream, there are memory fragments, numbered , and there are white fragments and black fragments.
She vaguely remembers that she needs to choose white fragments from the memory fragments with odd indices to form a memory, and choose black fragments from the memory fragments with even indices to form a memory, and the indices of the chosen fragments are pairwise non-adjacent.
She wants to know how many ways there are to choose them. That is, choose odd numbers and even numbers from , and the chosen numbers are pairwise non-adjacent.
Since the answer may be large, she only needs the result modulo .
Input Format
This problem has multiple test cases.
The first line contains the number of test cases .
The next lines each contain three integers .
Output Format
Output lines, each line containing one integer representing the answer.
6
2 1 1
4 2 1
114 5 14
1919 8 10
19260 8 17
114514 1919 810
1
6
43944630
803733835
204764788
713170605
Hint
Sample Explanation
For the first query, there are numbers in total. Choose one number from the odd set and one number from the even set . The only way to choose two non-adjacent numbers is .
For the second query, there are numbers in total. Choose numbers from the odd set and number from the even set . The chosen numbers must be pairwise non-adjacent. The valid choices are: , , , , , . There are ways in total.
The ranges of the later queries are too large, so no sample explanation is provided.
Constraints
This problem uses bundled testdata, with subtasks.
: , .
: , .
: , .
For of the testdata, it is guaranteed that .
Translated by ChatGPT 5
京公网安备 11011102002149号