#include #include using ll = long long; using ull = unsigned long long; #define rep(i, n) for(int i = 0; i < (int)(n); i++) #define REP(i, m, n) for(int i = (int)(m); i < (int)(n); i++) using namespace std; using namespace atcoder; using mint = modint998244353; const int inf = 1000000007; const ll longinf = 1ll << 60; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin >> n; vector> g(n); rep(i, n - 1) { int x, y; cin >> x >> y; --x; --y; g[x].push_back(y); g[y].push_back(x); } vector dp(n, vector(2, 0)); auto dfs = [&](auto &&self, int x, int p) -> void { int v0 = inf, v1 = -inf; for(auto to : g[x]) { if(to == p) { continue; } self(self, to, x); v0 = min(v0, dp[to][1] + 1); v1 = max(v1, dp[to][0] + 1); } if(v1 == -inf) { v0 = v1 = 0; } dp[x][0] = v0; dp[x][1] = v1; }; dfs(dfs, 0, -1); cout << dp[0][1] << endl; cout << dp[0][0] << endl; return 0; }