// Try yukicoder
// author: Leonardone @ NEETSDKASU
#include <iostream>
#include <set>
#include <vector>

using namespace std;

int main() {
    int n; cin >> n;
    set<string> s;
    vector<string> t;
    while (n--) {
        string a, b; cin >> a >> b;
        s.insert(a);
        t.push_back(b);
    }
    for (auto b : t) {
        if (s.find(b) == s.end()) {
            cout << b << endl;
            s.insert(b);
        }
    }
    
    return 0;
}