#include #include #include using namespace std; int main() { int n; cin >> n; vector A, B; set ok; while (n--) { string a, b; cin >> a >> b; A.push_back(a); B.push_back(b); ok.insert(b); } for (string &a : A) ok.erase(a); for (string &b : B) if (ok.find(b) != ok.end()) { cout << b << endl; ok.erase(b); } }