{"raw_statement":[{"iden":"problem statement","content":"We have $N$ chairs arranged in a circle, one of which is a throne.\nTakahashi is initially sitting on the chair that is $S$ chairs away from the throne in the clockwise direction. Now, he will repeat the move below.\nMove: Go to the chair that is $K$ chairs away from the chair he is currently sitting on in the clockwise direction.\nAfter how many moves will he be sitting on the throne for the first time? If he is never going to sit on it, report `-1` instead.\nYou are asked to solve $T$ test cases."},{"iden":"constraints","content":"*   $1\\leq T \\leq 100$\n*   $2\\leq N \\leq 10^9$\n*   $1\\leq S < N$\n*   $1\\leq K \\leq 10^9$"},{"iden":"input","content":"Input is given from Standard Input in the following format. The first line is in the format below:\n\n$T$\n\nThen, the following $T$ lines represent $T$ test cases. Each of these lines is in the format below:\n\n$N$ $S$ $K$"},{"iden":"sample input 1","content":"4\n10 4 3\n1000 11 2\n998244353 897581057 595591169\n10000 6 14"},{"iden":"sample output 1","content":"2\n-1\n249561088\n3571\n\nIn the first test case, we have $10$ chairs, and Takahashi is initially sitting on the chair that is $4$ chairs away from the throne in the clockwise direction. He will be sitting on the throne after $2$ moves of moving $3$ chairs in the clockwise direction.\nIn the second test case, he will never sit on the throne, so we should print `-1`."}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}