#include #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; typedef long long ll; int main(){ cin.tie(0); ios::sync_with_stdio(0); int N; cin >> N; map id; set st; vector ng(N); int ID = 0; rep(i,N) { string a,b; cin >> a >> b; if(!id.count(b)) id[b] = ID++; ng[i] = a; st.insert(b); } for(string &a : ng) st.erase(a); vector> ans; for(string s : st) ans.push_back({id[s], s}); sort(ans.begin(), ans.end()); for(auto [_, s] : ans) cout << s << "\n"; }