#P8249. 模法问题
模法问题
Description
You have two positive integers .
You also have a positive integer , and you need to process queries.
For each query, you are given two positive integers .
You need to find , where is a positive integer and .
Input Format
The first line contains two positive integers .
The second line contains one positive integer .
The next lines each contain two positive integers .
Output Format
For each query, output one line containing one integer, which is the answer.
5 7
4
1 5
5 7
33 34
34 35
8
7
10
10
Hint
For of the testdata, and .
For of the testdata, and .
For of the testdata, , , and .
Translated by ChatGPT 5
京公网安备 11011102002149号