#include <bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using ll = long long;
const int MX = 200005;
vector<int> g[MX];
int dis[MX];
int in[MX], out[MX], timer;
void dfs(int u, int p = -1) {
in[u] = timer++;
for (int v : g[u]) {
if (v == p) continue;
dis[v] = dis[u] + 1;
dfs(v, u);
}
out[u] = timer-1;
}
int main() {
FAST;
int n, i, u, v, x, ans;
cin >> n;
for (i = 1; i < n; ++i) {
cin >> u >> v;
--u; --v;
g[u].push_back(v);
g[v].push_back(u);
}
memset(dis, 0, sizeof(dis));
timer = 0;
dfs(0);
u = 0;
for (i = 0; i < n; ++i) {
if (dis[i] > dis[u]) u = i;
}
memset(dis, 0, sizeof(dis));
timer = 0;
dfs(u);
v = u;
for (i = 0; i < n; ++i) {
if (dis[i] > dis[v]) v = i;
}
ans = 0;
x = dis[v] / 2;
for (i = 0; i < n; ++i) {
if ((dis[i] == x) && (in[i] <= in[v]) && (in[v] <= out[i])) {
ans = max(ans, i);
}
}
if (dis[v] & 1) {
x = (dis[v] + 1) / 2;
for (i = 0; i < n; ++i) {
if ((dis[i] == x) && (in[i] <= in[v]) && (in[v] <= out[i])) {
ans = max(ans, i);
}
}
}
cout << x << " " << ans+1 << "\n";
return 0;
}