#include<bits/stdc++.h>
using namespace std;

typedef long long LL;
const LL INF = 0x3f3f3f3f;
const int maxn = 1005;
vector<int> G[maxn];
int n;
int treeVerN[maxn]; // 以 i 为根的树,节点总数
int center, childmax; // 重心,最大子树地节点个数
void dfs(int cur, int par)//current , parent
{
    treeVerN[cur] = 1; // 这棵树节点数目 包含根自身
    int childN = G[cur].size(), curCmax = -1;
    for(int i = 0;i < childN; ++i)
    {
        int childSeq = G[cur][i];
        if( childSeq != par){
            dfs(childSeq, cur);
            curCmax = max(curCmax, treeVerN[childSeq]);
            treeVerN[cur] += treeVerN[childSeq];
        }

    }

    curCmax = max(curCmax, n - treeVerN[cur]);
    if(curCmax < childmax)
    {
        center = cur;
        childmax = curCmax;
    }else if(curCmax == childmax)
    {
        center = min(center, cur);
    }

}
int main()
{
    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);

    while(cin >> n)
    {
        for(int i = 1;i <= n;++i)
            G[i].clear();
        center = -1, childmax = maxn;

        int u, v;
        for(int i = 1;i < n;++i)
        {
            cin >> u >> v;
            G[u].push_back(v);
            G[v].push_back(u);
        }

        dfs(1,-1);

        cout << center << " " << childmax;
    }


    return 0;
}