import java.io.*; import java.util.*; import java.util.function.*; import java.util.stream.*; public class Main { static List> graph = new ArrayList<>(); public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); for (int i = 0; i < n; i++) { graph.add(new ArrayList<>()); } for (int i = 0; i < n - 1; i++) { int a = sc.nextInt() - 1; int b = sc.nextInt() - 1; graph.get(a).add(b); graph.get(b).add(a); } System.out.println(search(0, 0, true)); System.out.println(search(0, 0, false)); } static int search(int idx, int p, boolean bigger) { if (bigger) { int ans = 0; for (int x : graph.get(idx)) { if (x != p) { ans = Math.max(ans, search(x, idx, bigger ^ true) + 1); } } return ans; } else { int ans = Integer.MAX_VALUE; for (int x : graph.get(idx)) { if (x != p) { ans = Math.min(ans, search(x, idx, bigger ^ true) + 1); } } return ans == Integer.MAX_VALUE ? 0 : ans; } } } class Scanner { BufferedReader br; StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() { try { br = new BufferedReader(new InputStreamReader(System.in)); } catch (Exception e) { } } public int nextInt() { return Integer.parseInt(next()); } public long nextLong() { return Long.parseLong(next()); } public double nextDouble() { return Double.parseDouble(next()); } public String next() { try { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } } catch (Exception e) { e.printStackTrace(); } finally { return st.nextToken(); } } }