#arc172e. E - Last 9 Digits
E - Last 9 Digits
问题陈述
判断是否存在正整数 ,使得 除以 的余数为 。如果存在,找出最小的 。
您需要解决 个测试用例。
以上为机器翻译结果,仅供参考。
Problem Statement
Determine whether there is a positive integer such that the remainder of divided by is . If it exists, find the smallest such .
You will be given test cases to solve.
Constraints
- is neither a multiple of nor a multiple of .
- All input values are integers.
Input
The input is given from Standard Input in the following format, where is the value of in the -th test case :
Output
Print lines. The -th line should contain the answer for the -th test case. If no satisfies the condition, the answer should be .
Sample Input 1
2
27
311670611
Sample Output 1
3
11
This sample input consists of two test cases.
- The first case: The remainder of divided by is , so satisfies the condition.
- The second case: The remainder of divided by is , so satisfies the condition.