|All-time Popular Problems|
|Detect cycle in an undirected graph|
|BFS traversal of graph|
|Two Mirror Trees|
|Delete nodes having greater value on right|
|Find the number of islands|
|Sum of all prime numbers between 1 and N.|
|Determine if Two Trees are Identical|
|Longest Palindrome in a String|
Consider circular track with n points marked as 1, 2, …n. A person is initially placed on point k. The person moves m > 0, slot forward (in circular way) in each step. Find the minimum number of steps required so that the person reaches initial point k.
The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case contains integers n,k,m.
Print the minimum number of steps required so that the person reaches initial point k.
9 2 6
6 3 2
Explanation: In the first test case, Sequence of moves is 2 => 8 => 5 => 2.So total number of moves are 3.