If the bus route is [3, 6, 7], then it will travel in sequence
3 > 6 > 7 > 3 > 6 > 7….
Values of A[i] are distinct.
The first line contains a single integer ‘T’ denoting the number of test cases.
The first line of the test case contains ‘N’, ‘SOURCE’, ‘TARGET’ denoting the number of buses, source station, and target station.
The next ‘N’ lines contain the stations that the bus will travel to.
The first integer of the ith line contains the total number of bus stations ith bus will travel to.
The next A[i][j] integers denote the bus station’s number of ith bus.
For each test case, return the single integer denoting the minimum number of buses to take to travel from source to destination. If it is not possible to reach destination return -1.
You don’t need to print anything. It has already been taken care of. Just implement the given function.
1 <= ‘T’ <= 10
1 <= ‘N’ <= 400
1 <= sum(length of A[i]) <= 10^5
0 <= A[i][j], ‘SOURCE’, ‘TARGET’ <=10^6
Time Limit: 1 sec
Longest Subarray With Zero Sum
Distance to a Cycle in Undirected Graph
Merge Two Sorted Arrays Without Extra Space
Ninja And The Strictly Increasing Array
Negative To The End