#CLSLDR. Class Leader
Class Leader
This is new year in Planet X and there is something special! A classroom in this planet is looking for a new class leader using an unique game!
These are the ways how the game is played.
- There are n students in the class. Each student is labeled from 1 (first student) to n (last student).
- A paper is given to m-th student.
- The next o-th student who gets the paper quits the game.
- The paper is passed until there is one last student who hasn't quitted the game.
- The student becomes the class leader.
Now, your task is to find the number of such student.
Input
The first line contains a number T (0 <= T <= 106).
Each of the next T lines contains 3 integers which are n (0 < n <= 103), m, o (0 < m, o <= n) and are separated by a single space.
Output
For each test cases, print the required answer.
Example
Input: 2 4 1 2 5 2 3</p>Output: 2 1
Explanation for Test Case 1
- 1 2 3 4 → The paper is being held by student 1. Pass the paper by 2 students. Now, the paper is being held by student 3.
- 1 2 4 → Student 3 quits. Pass the paper by 2 students. Now, the paper is being held by student 1.
- 2 4 → Student 1 quits. Pass the paper by 2 students. Now, the paper is being held by student 4.
- 2 → Student 4 quits. Student 2 becomes the class leader.