Given a Directed Graph, find a Mother Vertex in the Graph (if present).
A Mother Vertex is a vertex through which we can reach all the other vertices of the Graph.
The first line of input contains an integer T. Then T test cases follow. Each test case contains two integers V (number of vertices) and E (number of edges). In the next line are E space separated values u,v denoting an edge from u to v.
Output: For each testcase return the mother vertex of graph (if exists) else return -1.
You don't need to read input or print anything. Your task is to complete the function findMother() which takes a Directed graph and the number of vertices as inputs and returns a Mother Vertex in the Graph. If the graph has multiple Mother Vertices, return the one with the smallest value. If the Mother Vertex does not exist, return -1.
Expected Time Complexity: O(V + E). Expected Auxiliary Space: O(V).
1 <= T <= 500
1 <= V <= 500
1 <= E <= 3000
0 <= u, v < N