#P8302. [CoE R4 B/Stoi2041] 龙拳
[CoE R4 B/Stoi2041] 龙拳
Background
Problem Description
For , let be the largest proper divisor of (the largest divisor less than ), for example, .
Define . Let , and for we have .
There are multiple queries. For each query, given positive integers , find the smallest natural number such that for any , we always have .
If such an does not exist, let .
Input Format
The first line contains a positive integer , the number of queries.
The next lines each contain two positive integers , representing one query.
Output Format
For each query, output one integer as the answer.
2
2 3
3 4
0
-1
Hint
Sample Explanation
When , .
When , there is no that satisfies the condition.
Constraints
This problem uses bundled testdata.
- Subtask ( point): .
- Subtask ( points): .
- Subtask ( points): .
- Subtask ( points): .
- Subtask ( points): no special constraints.
For of the data, it is guaranteed that , , .
Translated by ChatGPT 5