#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);
}
auto bfs = [&](int start) -> pair<int, vector<int>> {
vector<int> dist(n, -1);
queue<int> q;
q.push(start);
dist[start] = 0;
int farthest_node = start;
int farthest = 0;
while (!q.empty()) {
int node = q.front();
q.pop();
for (int it : g[node]) {
if (dist[it] == -1) {
q.push(it);
dist[it] = dist[node] + 1;
if (dist[it] > farthest) {
farthest = dist[it];
farthest_node = it;
}
}
}
}
return {farthest_node, dist};
};
auto [first, distA] = bfs(0);
auto [second, distB] = bfs(first);
int diameter = distB[second];
int center = second;
for (int i = 0; i < diameter / 2; ++i) {
center = g[center][0];
}
cout << (diameter + 1) / 2 << " " << center + 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;
}