1.1 The Empty Gift

Score: 30pts

Time Limit: 1.00 sec

At a party, there are a certain number of gifts which have to be distributed. However, the last gift box is empty. All the guests are seated around a circular table in sequentially numbered chairs. A chair number is picked and beginning with the person on that chair one gift is given to each guest sequentially around the table until no gifts are left. Determine the chair number occupied by the guest who will receive that empty gift box.

Constraints

\(1 \leq t \leq 100\)

\(1 \leq n \leq 100\)

\(1 \leq m \leq 200\)

\(1 \leq s \leq n\)

\(1 \leq n \leq 100\)

\(1 \leq m \leq 200\)

\(1 \leq s \leq n\)

Input Format

The first line contains an integer \(t\) denoting the number of test cases.

The next \(t\) lines each contain space-separated integers:

- \(n\) : the number of guests

- \(m\) : the number of gifts

- \(s\) : the chair number where gift sharing starts

The next \(t\) lines each contain space-separated integers:

- \(n\) : the number of guests

- \(m\) : the number of gifts

- \(s\) : the chair number where gift sharing starts

Output Format

For each test case, print the chair number of the guest who receives the empty gift box on a new line

Example 1

Input:

2

5 2 1

5 2 2

Output:

2

3

Explanation:

In the first query, there are \(n=5\) guests and \(m=2\) gifts. Distribution starts at seat number \(s=1\). Guests in seats numbered 1 and 2 get gifts. Guest 2 gets the empty box.

In the second query, distribution starts at seat 2 so guests in seats 2 and 3 get sweets. Guest 3 gets the empty box.

2

5 2 1

5 2 2

Output:

2

3

Explanation:

In the first query, there are \(n=5\) guests and \(m=2\) gifts. Distribution starts at seat number \(s=1\). Guests in seats numbered 1 and 2 get gifts. Guest 2 gets the empty box.

In the second query, distribution starts at seat 2 so guests in seats 2 and 3 get sweets. Guest 3 gets the empty box.

Example 2

Input:

2

7 19 2

3 7 3

Output:

6

3

Explanation:

In the first test case \(n=7\), these are guests, \(m=19\) gifts and they are passed out starting at chair \(s=2\). The gifts go all-around twice and there are 5 more gifts passed to each guest from seat 2 to seat 6.

In the second test case, there are \(n=3\) guests, \(m=7\) gifts and they are passed out starting at seat \(s=3\). They go around twice, and there is one more to pass out to the guest at seat 3.

2

7 19 2

3 7 3

Output:

6

3

Explanation:

In the first test case \(n=7\), these are guests, \(m=19\) gifts and they are passed out starting at chair \(s=2\). The gifts go all-around twice and there are 5 more gifts passed to each guest from seat 2 to seat 6.

In the second test case, there are \(n=3\) guests, \(m=7\) gifts and they are passed out starting at seat \(s=3\). They go around twice, and there is one more to pass out to the guest at seat 3.