N = int(input()) AB = [list(map(int,input().split())) for _ in range(N-1)] E = [[] for _ in range(N)] for a,b in AB: a -= 1 b -= 1 E[a].append(b) E[b].append(a) X = [0] * N P = [-1] * N def dfs(x,p): tmp = 1 for y in E[x]: if y != p: P[y] = x tmp += dfs(y,x) X[x] = tmp return tmp def search(a): q = [0] cnt = 0 while q: q2 = [] while q: tmp = [] x = q.pop(-1) if (cnt+a) & 1: maxy = 0 for y in E[x]: if P[x] != y: if X[y] > maxy: tmp = [y] maxy = X[y] elif X[y] == maxy: tmp.append(y) #print("a",tmp,maxy) else: minx = N for y in E[x]: if P[x] != y: if X[y] < minx: tmp = [y] minx = X[y] elif X[y] == minx: tmp.append(y) #print("b",tmp,minx) q2 += tmp cnt += 1 q,q2 = q2,q return cnt dfs(0,-1) print(search(1)-1) print(search(0)-1)