#include using namespace std; using ll = long long; typedef pair vsi; auto compare = [](const vsi& x, const vsi& y) { return x.second > y.second; }; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector va(n); unordered_map m; for (int i = 0; i < n; ++i) { string b; cin >> va[i] >> b; if (!m.count(b)) m[b] = i; } priority_queue, decltype(compare)> que{ compare }; for (int i = 0; i < n; ++i) { auto it = m.find(va[i]); if (it != m.end()) m.erase(it); } for (const auto& im : m) { vsi elm{ im.first, im.second }; que.push(elm); } while (!que.empty()) { vsi elem = que.top(); cout << elem.first << "\n"; que.pop(); } return 0; }