1 #include<cstdio>
2 #include<cstdlib>
3 #include<cstring>
4 #include<iostream>
5 #include<algorithm>
6 using namespace std;
7 #define INF 0xfffffff
8 #define Maxn 200010
9
10 int mymax(int x,int y) {return x>y?x:y;}
11 int mymin(int x,int y) {return x<y?x:y;}
12
13 int mx[Maxn],mn[Maxn];
14
15 struct node
16 {
17 int x,y,next;
18 }t[Maxn];
19 int first[Maxn],len;
20 void ins(int x,int y)
21 {
22 t[++len].x=x;t[len].y=y;
23 t[len].next=first[x];first[x]=len;
24 }
25
26 int sm[Maxn];
27 void dfs(int x,int dep)
28 {
29 sm[x]=0;
30 if(first[x]==0)
31 {
32 sm[x]=1;
33 mn[x]=mx[x]=1;return;
34 }
35 for(int i=first[x];i;i=t[i].next)
36 {
37 int y=t[i].y;
38 dfs(y,dep^1);
39 sm[x]+=sm[y];
40 }
41 mx[x]=0;mn[x]=0;
42 if(dep) mx[x]=1,mn[x]=INF;
43 for(int i=first[x];i;i=t[i].next)
44 {
45 int y=t[i].y;
46 if(!dep)
47 {
48 mx[x]=mymax(mx[x],sm[x]-(sm[y]-mx[y]));
49 mn[x]+=mn[y];
50 }
51 else
52 {
53 mx[x]+=mx[y]-1;
54 mn[x]=mymin(mn[x],mn[y]);
55 }
56 }
57 }
58
59 int main()
60 {
61 int n;
62 scanf("%d",&n);
63 int rt=0;
64 for(int i=1;i<=n;i++) rt+=i;
65 len=0;
66 memset(first,0,sizeof(first));
67 for(int i=1;i<n;i++)
68 {
69 int x,y;
70 scanf("%d%d",&x,&y);
71 ins(x,y);
72 rt-=y;
73 }
74 dfs(rt,0);
75 printf("%d %d\n",mx[rt],mn[rt]);
76 return 0;
77 }