#K64012. Engagement Levels in a Conversation Tree

    ID: 31881 Type: Default 1000ms 256MiB

Engagement Levels in a Conversation Tree

Engagement Levels in a Conversation Tree

You are given a tree representing a conversation structure with N users (nodes) and N-1 edges. The tree is rooted at node 1. The engagement level of each user is defined as twice the distance from the root. That is, for a user at distance d from the root, their engagement level is given by the formula: \(2 \times d\).

Your task is to compute the engagement level for each user in the tree for multiple test cases.

Note: The tree is undirected and the input guarantees a valid tree structure for each test case.

inputFormat

The first line of input contains an integer T, the number of test cases.

Each test case begins with a line containing an integer N, the number of users (nodes) in the conversation tree. The next N-1 lines each contain two integers u and v which indicate an edge between user u and user v.

All input is provided via standard input (stdin).

outputFormat

For each test case, output a single line containing N space-separated integers, where the i-th integer represents the engagement level of user i.

All output should be printed to standard output (stdout).

## sample
3
1
2
1 2
4
1 2
1 3
2 4
0

0 2 0 2 2 4

</p>