#include <bits/stdc++.h>
using namespace std;
#define SC scanf
#define PF printf
#define ull unsigned long long
#define ld long double
#define F first
#define S second
#define pb push_back
#define sort_a(a) sort(a.begin(),a.end());
#define sort_d(a) sort(a.rbegin(),a.rend());
#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)
#define rev(s) reverse(s.begin(),s.end())
#define P(ok) cout << (ok ? "YES\n": "NO\n")
#define __Heart__ ios_base :: sync_with_stdio(false); cin.tie(NULL);
#define ll long long
typedef pair< ll , ll> PII;
const int MX = 1e5 + 5 ;
vector<int> Edge[MX] ;
int cnt = 0 , days = 0 , n , u , v , farthestNode = 0 , lev[MX] , mnDays;
void dfs(int id , int par){
for(auto child : Edge[id]){
if(child != par){
lev[child] = lev[id] + 1 ;
if(days < lev[child]){
days = lev[child] ;
farthestNode = child ;
}
dfs(child , id) ;
}
}
}
void solve()
{
cin >> n ;
for(int i = 1 ; i < n ; i++){
cin >> u >> v ;
Edge[u].pb(v) ;
Edge[v].pb(u) ;
}
dfs(1 , -1) ;
for(int i = 1 ; i <= n ; i++) lev[i] = 0;
dfs(farthestNode , -1) ;
mnDays = (days + 1) >> 1 ;
vector < int > node ;
for(int i = n ; i >= 1; i--){
if(days % 2 == 0){
if(lev[i] == mnDays && Edge[i].size() > 1){
cout << mnDays << " " << i << endl ;
break ;
}
}
else {
if((lev[i] == mnDays && Edge[i].size() > 1) || (lev[i] == mnDays - 1 && Edge[i].size() > 1)){
cout << mnDays << " " << i << endl ;
break ;
}
}
}
// for(int i = node.size() - 1 ; i >= 0 ; i--){
// lev[node[i]] = 0 ;
// days = 0 ;
// dfs(node[i] , -1) ;
// if(days == mnDays){
// cout << mnDays << " " << node[i] << endl ;
// break ;
// }
// }
}
int main()
{
__Heart__
int t ; t = 1 ; while(t--) solve() ;
}