#include "bits/stdc++.h" #define REP(i, n) for(int i = 0; i < int(n); i++) #define FOR(i,n,m) for(int i = int(n); i < int(m); i++) using namespace std; typedef long long ll; const int MOD = 1e9 + 7; const int INF = 1e9 + 6; const ll LLINF = 1e18 + 1; int main() { int n; cin >> n; map mp; vector ans; REP(i, n) { string s, t; cin >> s >> t; if (mp.find(s) == mp.end()) ans.push_back(s); if (mp.find(t) == mp.end()) ans.push_back(t); mp[s] = -1; if (mp.find(t) == mp.end() || mp[t] != -1) mp[t] = 1; } REP(i, ans.size()) { if (mp[ans[i]] == 1) { cout << ans[i] << endl; } } return 0; }