Rikka with Tree Game

루트가 있는 트리에서 두 사람이 번갈아 토큰을 아래로 옮길 때, 최종 깊이를 정확히 k로 만들기 위해 더해야 하는 최소 리프 수 f(k)의 f(k)/k 극한을 구한다.

어려움9게임 이론트리DFS그리디아직 제출이 없습니다시간 제한2초메모리 제한512 MB

문제

Game theory is an important branch of computer science. So, for a college student who is a computer science major, playing games may not always be an enjoyable process.

Today, Rikka is doing some research about a simple but interesting game with trees.

Consider a rooted tree TT. Initially, there is a token on the root. Two players play a game on this tree, taking turns to move the token. On each turn, assuming the token's position is vertex ii, the player needs to choose a child jj of ii and move the token to jj. If ii has no child, the game ends immediately.

The final score of the game is the depth of the final position of the token (the depth of the root is 11, and the depth of every other vertex is 11 plus the depth of its parent). The first player wants to maximize the score, while the second player wants to minimize the score. Assume that both players play optimally.

Given a rooted tree TT, calculating the final score of the game is a simple task. So Rikka wants to solve a more challenging problem. She can do some operations to the tree: each time, she can choose a leaf ii of the tree (a leaf is a vertex which does not have any children) and link a new node to the tree with node ii as its parent.

Let f(k)f(k) be the minimum number of operations to make the game's final score be exactly kk, assuming that both players play optimally. If it is impossible, let f(k)f(k) be 1-1. Rikka wants to know the value lim_k+f(k)k\lim\limits\_{k \rightarrow +\infty}\frac{f(k)}{k}.

You know, Rikka is good at asking questions, but not as good at answering them. So, she asks you for help.

입력

The first line contains a single integer tt (1t1031 \leq t \leq 10^3), the number of test cases.

For each test case, the first line contains an integer nn (1n1051 \leq n \leq 10^5).

Then n1n - 1 lines follow. Each of them contains two integers uu and vv (1u,vn1 \leq u, v \leq n) which describe an edge (u,v)(u, v) of the tree. The index of the root is 11.

It is guaranteed that the given graphs are trees. It is also guaranteed that there are at most 1010 test cases with n>1000n > 1000.

출력

For each test case, print a single line with a single integer: the value of the limit Rikka wants to know. (It turns out that, if the answer exists, it is an integer.) If the limit does not exist, print 1-1 instead.