#include<bits/stdc++.h>
using namespace std;
const int N=1e6;
int n;
int fst[N],to[N*2],nex[N*2],tot;
int size[N];
int ma[N];
int cnt[N];
int ans;
int len;
int mi=INT_MAX,d;
void add(int x,int y){
to[++tot]=y;
nex[tot]=fst[x];
fst[x]=tot;
}
void dfs1(int x,int f){
size[x]=1;
for(int i=fst[x];i;i=nex[i]){
if(to[i]!=f){
dfs1(to[i],x);
size[x]+=size[to[i]];
}
}
}
void dfs2(int x,int f,int dis){
len+=dis;
for(int i=fst[x];i;i=nex[i]){
if(to[i]!=f) dfs2(to[i],x,dis+1);
}
}
int main(){
cin>>n;
for(int i=1;i<n;i++){
int x,y;
cin>>x>>y;
add(x,y);
add(y,x);
}
dfs1(1,1);
for(int i=1;i<=n;i++){
int t,m;
t=n-size[i];
m=size[i]-1;
ma[i]=max(t,m);
if(ma[i]<mi){
mi=ma[i];
d=i;
}
}
for(int i=1;i<=n;i++){
if(ma[i]==mi) cnt[i]=1;
}
for(int i=1;i<=n;i++){
if(cnt[i]){
ans=i;
break;
}
}
dfs2(ans,ans,0);
cout<<ans<<" "<<len;
return 0;
}