Given a linked list which can have a loop, find the node at which the loop starts. If no loop exists, return NULL.
The first line contains an integer ‘T’ denoting the number of independent test cases.
For each test case the input has three lines:
Note: m is in the range [0, n-1] for valid loop. A value of -1 indicates no loop.
For each test case, a line containing the value of the node at which the loop starts.
3
3
3 4 5
1
4
1 2 3 4
0
3
5 6 7
-1
4
1
-1
1 <= T <= 100
1 <= n <= 104
-1 <= m < n
1 <= node value <= 105