270 传统题

[CF2290H] 额外道路 (Extra Road)

时间限制
2000ms
内存限制
256MiB
登顶 / 尝试
1/ 1
难度
5

[CF2290H] 额外道路 (Extra Road)

Problem Statement

There are nn cities numbered 11 through nn, connected by n−1n - 1 bidirectional roads forming a tree. City 11 is the capital.

First, you must build exactly one new bidirectional road between two distinct cities that are not already directly connected by a road.

Then, an adversary observes your network and permanently closes exactly one of the nn existing roads (either one of the original n−1n - 1 roads or your newly built road). A city is considered reachable if there is a path from the capital 11 to it using the remaining n−1n - 1 open roads (city 11 is always reachable).

Choose where to add the extra road so as to maximize the minimum possible number of reachable cities in the worst case, and print this maximum number.

Input

The first line contains tt (1≤t≤1041 \le t \le 10^4) — the number of test cases.

The first line of each test case contains nn (3≤n≤2⋅1053 \le n \le 2 \cdot 10^5). The next n−1n - 1 lines each contain two integers uu and vv (1≤u,v≤n1 \le u, v \le n, u≠vu \ne v) describing an edge of the tree.

It is guaranteed that the sum of nn over all test cases does not exceed 2⋅1052 \cdot 10^5.

Output

For each test case, print a single integer — the maximum guaranteed number of reachable cities.

Example

5
3
1 2
2 3
4
1 2
1 3
1 4
6
1 2
2 3
2 4
3 5
4 6
5
2 1
1 3
2 4
3 5
6
1 2
2 3
3 4
3 5
3 6
3
3
4
5
5

Note

  • Constraints: 1≤t≤1041 \le t \le 10^4, 3≤n≤2⋅1053 \le n \le 2 \cdot 10^5, ∑n≤2⋅105\sum n \le 2 \cdot 10^5.
  • Source: Codeforces 2290H · Extra Road