#include using namespace std; using ll = long long; int main(){ cin.tie(nullptr); ios_base::sync_with_stdio(false); //dp(i, j) : 頂点iにプレイヤーjがいる状態で始めた時のターン数 int N, a, b; cin >> N; vector> E(N+1); for (int i=1; i<=N-1; i++){ cin >> a >> b; E[a].push_back(b); E[b].push_back(a); } vector dp(N+1, vector(2)); for (int i=1; i<=N; i++) dp[i][1] = 1e9; auto dfs=[&](auto self, int from, int p)->void{ if (p != -1 && E[from].size() == 1){ dp[from][0] = 0; dp[from][1] = 0; return; } for (auto to : E[from]){ if (to == p) continue; self(self, to, from); //Halcは最大化 dp[from][0] = max(dp[from][0], dp[to][1]+1); //Sappは最小化 dp[from][1] = min(dp[from][1], dp[to][0]+1); } }; dfs(dfs, 1, -1); if (N == 1) dp[1][1] = 0; cout << dp[1][0] << endl; cout << dp[1][1] << endl; return 0; }