#include using namespace std; #define SZ(x) (int)(x.size()) using ll = long long; using ld = long double; using P = pair; using vi = vector; using vvi = vector>; using vll = vector; using vvll = vector>; const double eps = 1e-10; const int MOD = 1000000007; const int INF = 1000000000; const ll LINF = 1ll<<50; template void printv(const vector& s) { for(int i=0;i<(int)(s.size());++i) { cout << s[i]; if(i == (int)(s.size())-1) cout << endl; else cout << " "; } } int main() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(10); int n; cin >> n; map mp; set> st; for(int i=0;i> s1 >> s2; st.insert({i, s2}); mp[s1] = true; } set ans; for(auto &e: st) { if(!mp[e.second]) { ans.insert(e.second); } } for(auto &e: ans) { cout << e << endl; } }