#include using namespace std; void fast_io() { ios::sync_with_stdio(false); std::cin.tie(nullptr); } vector> g; vector deg; vector is_leaf; vector mi, ma; void dfs(int u, int pre) { if (u && is_leaf[u]) { mi[u] = 0, ma[u] = 0; return; } mi[u] = 1e9; for (int v : g[u]) { if (v == pre) { continue; } dfs(v, u); mi[u] = min(mi[u], ma[v] + 1); ma[u] = max(ma[u], mi[v] + 1); } } int main() { fast_io(); int n; cin >> n; g.resize(n); deg.resize(n); is_leaf.resize(n, true); for (int i = 0; i < n - 1; i++) { int a, b; cin >> a >> b; a--; b--; g[a].push_back(b); g[b].push_back(a); deg[a]++; if (deg[a] > 1) is_leaf[a] = false; deg[b]++; if (deg[b] > 1) is_leaf[b] = false; } if (n == 1) { cout << "0\n0\n"; return 0; } mi.resize(n); ma.resize(n); dfs(0, -1); cout << ma[0] << "\n"; cout << mi[0] << "\n"; }