#P9035. 「KDOI-04」Pont des souvenirs
「KDOI-04」Pont des souvenirs
Background
Although this is a C, it still is.

Problem Description
Given positive integers , find how many positive integer sequences of length satisfy:
- ;
- , .
Output the answer modulo .
Input Format
This problem contains multiple test cases.
The first line contains a positive integer , the number of test cases.
For each test case, the input contains one line with two positive integers .
Output Format
For each test case, output one line with one integer, representing the answer.
5
2 2
1 3
4 5
4030 218
1145 1419
2
3
20
571656908
172735629
Hint
[Sample Explanation]
For the st test case, all sequences that satisfy the requirements are and .
For the nd test case, all sequences that satisfy the requirements are , , and .
[Constraints]
For of the testdata, it is guaranteed that , .
This problem uses bundled test cases.
| Subtask ID | Points | |||
|---|---|---|---|---|
Translated by ChatGPT 5