

The first line of input contains an integer 'T', the number of test cases.
The first line of the test case contains a single integer ‘N’.
From the second line onwards next 'N-1' lines denote the edges of the graph.
Each edge is characterized by two integers 'A' and 'B' where 'A' and 'B' denote the endpoints of the edge. The edges[i][0], edges[i][1] contains the endpoints of edges.
For each test case, return the list where the ith element denotes the distance of the ith vertex from all others vertices.
You are not required to print the expected output; it has already been taken care of. Just implement the function.
1 <= T <= 50
1 <= N <= 10^3
0 <= edges[i][0], edges[i][1] <= N-1
Total number of edges = N-1
Time Limit: 1 sec
The key idea is to apply bfs/dfs from each vertex to find distance from all vertices.
Algorithm:
The main idea is we will find sum of the distance between parent and all the nodes in the subtree of parent.. Also we will find a number of children of every parent.Then we will find the answer for every child using the parent’s answer such that ANS[j]=ANS[i]-SUBTREE[j]+(N-2-SUBTREE[j]).
(N-2-SUBTREE[j] means excluding the children count of j).
Algorithm: