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

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n; cin >> n;
	vector<string> candidates;
	set<string> cheaters;
	string s;
	for (int i = 0; i < n; ++i) {
		cin >> s;
		cheaters.insert(s);
		cin >> s;
		candidates.push_back(s);
	}

	set<string> named;
	for (int i = 0; i < candidates.size(); ++i) {
		if (cheaters.count(candidates[i]) == 0 
			&& named.count(candidates[i]) == 0) 
			cout << candidates[i] << endl;
		named.insert(candidates[i]);
	}
	return 0;
}