#include using namespace std; #define REP(i,n) for(int i=0; i<(int)(n); i++) int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; set ng; vector cand(n); REP (i, n) { string tmp; cin >> tmp >> cand[i]; ng.insert(tmp); } REP (i, n) { if (!ng.count(cand[i])) { cout << cand[i] << endl; ng.insert(cand[i]); // remove dupilicate } } return 0; }