#include <iostream>
#include <set>
#include <vector>
using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	string s;
	set<string> bad;
	vector<string> good;
	cin >> n;
	while (n--) {
		cin >> s;
		bad.insert(s);
		cin >> s;
		good.push_back(s);
	}
	for (string i : good) if (bad.find(i) == bad.end()) {
		cout << i << endl;
		bad.insert(i);
	}
}