#15853. [SNCPC2019] K-hour Clock
[SNCPC2019] K-hour Clock
[SNCPC2019] K-hour Clock
题目描述
A $k$-hour clock is a day keeping method which follows the rules below:- A day is divided into hours, where the -th hour is called the o' clock;
- If it's o'clock now, it will be o'clock after hour if ;
- If it's o'clock now, it will be o'clock after hour.
We know that it's o'clock now, and after hours it will be o'clock. What's the value of ?
输入格式
There are multiple test cases. The first line of the input is an integer $T$ (about $10^5$), indicating the number of test cases. For each test case:The first and only line contains three integers , and (, ).
输出格式
For each test case output one line containing one integer, indicating the value of $k$. Note that there must be $1 \le k \le 2 \times 10^9$. If there are multiple valid answers, you can print any of them; If there is no valid answer, print ``-1`` (without quotes) instead.4
11 18 5
3 49 4
1 9 1
1 3 10
12
24
3
-1