

1. The judge trust nobody
2. Everybody trusts the judge
3. There is only one judge.
Note that the judge is also numbered similar to the rest of the town members.
The first line contains an integer ‘T’ which denotes the number of test cases.
The first line of each test case contains two space-separated integers ‘N’ and ‘X’, denoting the number of people in the town and the number of queries regarding who trusts whom.
The next ‘X’ lines of each test contain an array of ‘X’ pairs where each pair denotes who trusts whom in the town.
For each test case, you need to return a single integer denoting the judge.
Print the output of each test case in a separate line.
You don’t need to print anything; It has already been taken care of. Just implement the given function.
1 <= T <= 10
1 <= N <= 1000
0 <= X <= 1000
1 <= Y1, Y2 <= N
Where 'Y1' and 'Y2' denotes who trusts whom in the town.
Time limit: 1 sec
In this approach, we will be creating two arrays to count the number of incoming and outgoing edges on a certain person. For any outgoing edges let’s say from A to B, we will surely know that A is not the judge, as A trusts B but a judge doesn't trust anyone.
For incoming edges A to B, we increment the counter of count[B], where the count is the array used. When we know there are ‘N’ - 1 incoming connection, we store B, as it is a possible candidate for being the judge, and move forward. If we come through another candidate let’s say C that also has ‘N’ - 1 incoming connection, we know that no possible judge or answer is valid. So return -1.
The steps are as follows: