#include<iostream> #include<cstdio> #include<queue> usingnamespace std; constint N = 1e5 + 10, M = 1e5 + 10; bool vis[N]; int n, cnt, din[N], dout[N], flow[N]; int idx = -1, hd[N], nxt[M], edg[M]; voidadd(int a, int b) { nxt[++idx] = hd[a]; hd[a] = idx; edg[idx] = b; } intmain() { cin >> n; for (int i = 1; i <= n; i++) hd[i] = -1; for (int i = 1, a, b; i < n; i++) { cin >> a >> b; add(a, b); din[b]++; dout[a]++; } queue <int> q; for (int i = 1; i <= n; i++) if (!din[i]) { cnt++; flow[i] = 1; vis[i] = true; q.push(i); } while (!q.empty()) { int t = q.front(); q.pop(); if (dout[t] > 1) continue; for (int i = hd[t]; ~i; i = nxt[i]) { flow[edg[i]] += flow[t]; din[edg[i]]--; if (!din[edg[i]]) q.push(edg[i]); } } for (int i = 1; i <= n; i++) if (flow[i] == cnt && !vis[i]) cout << i << endl; return0; }