Universal Cup Judging System

Universal Cup

Süre Sınırı: 1.0 s Bellek Sınırı: 1024 MB Toplam puan: 100 Hack'lenebilir ✓
İstatistikler

Given an unrooted tree with $n$ nodes, you need to assign a distinct weight to each node, with weights forming a permutation of the numbers from $1$ to $n$.

For any assignment scheme, we consider all diameters of the tree (i.e., the longest simple path in the tree). Among these diameters, we select the one with the lexicographically largest weight sequence (arranging the weights of the nodes along the path in order and comparing lexicographically).

Your goal is to minimize the lexicographic order of the weight sequence corresponding to this "lexicographically largest diameter" among all possible assignment schemes.

Input

A single test case contains multiple data groups.

The first line of input is the number of data groups $T$ ($1 \le T \le 10^5$), representing the number of data groups in this test case.

For each data group, the first line contains an integer $n$ ($2 \le n \le 2 \cdot 10^5$) indicating the number of nodes.

The next $n - 1$ lines each contain two integers $u, v$ ($1 \le u, v \le n$), representing an edge of the tree.

It is guaranteed that across all data, $\sum n \le 2 \cdot 10^5$.

Output

For each set of data, output a line of several integers representing the smallest possible lexicographical order of the diameter with the largest lexicographical order.

Example

Input

5
5
1 2
1 3
2 4
2 5
4
1 2
1 3
1 4
6
1 2
1 3
2 4
2 5
3 6
8
1 2
2 3
1 4
2 5
3 6
1 7
7 8
10
1 2
2 3
2 4
4 7
4 8
1 5
5 6
6 9
1 10

Output

3 4 5 1
3 4 2
3 4 5 6 1
2 3 4 5 6 1
3 4 5 6 7 8 1

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.