

The first line of input contains an integer 'T' representing the number of test cases.
The first line of each test case contains a single integer, ‘N’, where ‘N’ denotes the total number of nodes in the given graph.
The next ‘N’ - 1 lines contains two space-separated integers, ‘U’ and ‘V’, where ‘U’ and ‘V’ represent the nodes that share a directed edge from ‘U’ to ‘V’.
For each test case, print the minimum number of operations required to make a directed path from each node to node 0.
The output of each test case will be printed in a separate line.
1 <= T <= 5
1 <= N <= 3000
0 <= U, V <= N - 1
Time Limit : 1sec
You do not need to print anything, it has already been taken care of. Just implement the given function.
The idea here is to convert the given directed acyclic graph into a bidirectional acyclic graph by adding reverse edges, i.e., for every edge present in the graph, we will add an edge with opposite direction.
For example:
Below, the left side directed graph will be converted into the right side undirected graph.
The edges marked in red are reverse edges.
Then we will do a depth-first search from node 0 and count the number of edges that are not reverse edges.
This function is used to traverse the given graph and count the number of non-reverse edges.
This function will take three parameters :
int depthFirstSearch(root, parent, adjList):
The idea is similar to the previous approach, but now we will do a breadth-first search from node 0 and count the number of non-reverse edges.