There are $N$ villages numbered $1$ to $N$. The villages are connected through bi-directional paths in between them. The whole network is in the form of a tree. 
Each village has only $1$ fighter but they help each other in times of crisis by sending their fighter to the village in danger through paths along the villages. Defeating a fighter will mean conquering his village. In particular, If village $X$ is under attack, all villages having a path to $X$ will send their fighters for help. 
Naruto wants to conquer all the villages. But he cannot take on so many fighters at the same time so he plans to use  a secret technique with which he can destroy  any $1$ village (along with paths connected to it) in the blink of an eye.  However, it can be used only once. He realized that if he destroys any village, say $X$, the maximum number of fighters he has to fight at once reduces to $W$. He wants $W$ to be as small as possible. Help him find the optimal $X$.
In case of multiple answers, choose the smallest value of $X$.

-----Input:-----
- First line will contain $T$, number of testcases. Then the testcases follow. 
- First Line contains $N$.
- Next $N - 1$ lines contain $U, V$, denoting a path between village $U$ and $V$. 

-----Output:-----
- For each Test case, print in a new line, optimal $X$ and corresponding value of $W$.

-----Constraints-----
- $1 \leq T \leq 10$
- $3 \leq N \leq 10^5$
- $1 \leq U, V \leq N$ 
- $U != V$ 

-----Sample Input:-----
2
5
1 2
1 3
2 4
3 5
3
1 2
2 3

-----Sample Output:-----
1 2
2 1

-----EXPLANATION:-----
Sample 1:  By destroying village $1$,  The fighters Naruto will be fighting at the same time will be from villages $[2, 4]$ and $[3, 5]$.  For this $W$ = $2$. No other choice can give lesser $W$. Hence $1$ is optimal choice.

```python

USER_FILENAME = "<user_code>"
import sys, json, builtins
import math, heapq, bisect, itertools, functools, collections, statistics, fractions, decimal, operator, array, random, re, string, os, pathlib
try:
    import resource as _res
except Exception:
    _res = None
from collections import Counter, defaultdict, deque, OrderedDict
from functools import lru_cache, reduce
from itertools import accumulate, permutations, combinations, product
from math import gcd, ceil, floor, sqrt
from decimal import Decimal
try:
    from typing import *
except Exception:
    pass
try:
    sys.setrecursionlimit(1_000_000)
except Exception:
    pass
try:
    import site as _site
    try:
        _sys_sites = _site.getsitepackages() if hasattr(_site, "getsitepackages") else []
        for _p in _sys_sites:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
    try:
        _usp = _site.getusersitepackages()
        if isinstance(_usp, str):
            _usp = [_usp]
        for _p in _usp:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
except Exception:
    pass

ns = {"__name__": "__main__"}
for _k, _v in list(globals().items()):
    if not _k.startswith("_"):
        ns[_k] = _v
_CODE = "# cook your dish here\ndef solve(edges,ans):\n n = len(edges)\n visited = set()\n parents = [-1]*(n+1)\n dp = [0]*(n+1)\n stack = [1]\n w = float('inf')\n x = -1\n while stack:\n  node = stack[-1]\n  if node not in visited:\n   count = 0\n   for kid in edges[node]:\n    if parents[kid] == -1:\n     if kid != 1:\n      parents[kid] = node\n    else:\n     if kid != parents[node]:\n      if kid in visited:\n       count += 1\n      else:\n       stack.append(kid)\n\n   if node == 1:\n    count -= 1\n   if count == len(edges[node])-1:\n    stack.pop()\n    visited.add(node)\n    max_val = 0\n    for kid in edges[node]:\n     dp[node] += dp[kid]\n     max_val = max(max_val,dp[kid])\n\n    dp[node] += 1\n\n    max_val = max(max_val,n-dp[node])\n    if max_val < w:\n     w = max_val\n     x = node\n    elif max_val == w:\n     x = min(x,node)\n\n ans.append(str(x)+' '+str(w))\n  \ndef main():\n t = int(input())\n ans = []\n for i in range(t):\n  n = int(input())\n  edges = {}\n  for j in range(1,n+1):\n   edges[j] = []\n\n  for j in range(n-1):\n   x,y = list(map(int,input().split()))\n   edges[x].append(y)\n   edges[y].append(x)\n\n  solve(edges,ans)\n\n print('\\n'.join(ans))\n\nmain()\n"
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 13895