#P4449. 于神之怒加强版
于神之怒加强版
Description
Given , compute
and output the result modulo .
Input Format
There are multiple test cases in a single test file.
The first line contains two integers, the number of test cases and the given .
The next lines each contain two integers, and , for one test case.
Output Format
For each test case, output one line with a single integer representing the answer.
1 2
3 3
20
Hint
Constraints
For all test points, it is guaranteed that , .
Translated by ChatGPT 5
京公网安备 11011102002149号