#include <bits/stdc++.h>
using namespace std;
void solve(int cs) {
int n;
cin >> n;
vector<vector<int>> g(n);
for (int i = 0; i < n - 1; i++) {
int u, v;
cin >> u >> v;
--u, --v;
g[u].push_back(v);
g[v].push_back(u);
}
vector<int> dist(n, -1), par(n, -1);
auto bfs = [&](int st) -> vector<int> {
queue<int> q;
q.push(st);
dist[st] = 0;
par[st] = -1;
int farthest = st;
while (!q.empty()) {
int node = q.front();
q.pop();
for (int neighbor : g[node]) {
if (dist[neighbor] == -1) {
q.push(neighbor);
par[neighbor] = node;
dist[neighbor] = dist[node] + 1;
if (dist[neighbor] > dist[farthest]) {
farthest = neighbor;
}
}
}
}
return par;
};
par = bfs(0);
int A = max_element(dist.begin(), dist.end()) - dist.begin();
dist.assign(n, -1);
par = bfs(A);
int B = max_element(dist.begin(), dist.end()) - dist.begin();
vector<int> path;
for (int v = B; v != -1; v = par[v]) {
path.push_back(v);
}
int len = path.size();
int days = (len - 1) / 2;
int node = path[len / 2];
if (len % 2 == 0) {
node = max(node, path[len / 2 - 1]);
}
cout << days << " " << node + 1 << "\n";
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int tc = 1;
// cin >> tc;
for (int cs = 1; cs <= tc; cs++) {
solve(cs);
}
return 0;
}