import sys input = sys.stdin.readline def non_rec_dfs(s, G, c): N = len(G) stack = [] stack.append(s) par = [-1] * N depth = [-1] * N sz = [1] * N depth[s] = 0 dp = [-1] * N inf = 10 ** 18 while stack: u = stack.pop() if u >= 0: stack.append(~u) for v in G[u]: if v == par[u]: continue par[v] = u depth[v] = depth[u] + 1 stack.append(v) else: u = ~u if len(G[u]) == 1 and par[u] != -1: dp[u] = 1 continue sz[par[u]] += sz[u] if depth[u] % 2 == c: val = inf for v in G[u]: if v == par[u]: continue val = min(val, dp[v]) else: val = -inf for v in G[u]: if v == par[u]: continue val = max(val, dp[v]) dp[u] = val + 1 return dp[0] N = int(input()) G = [[] for i in range(N)] for i in range(N - 1): u, v = map(int, input().split()) u, v = u - 1, v - 1 G[u].append(v) G[v].append(u) if N == 1: print(0) print(0) exit() print(non_rec_dfs(0, G, 1)-1) print(non_rec_dfs(0, G, 0)-1)