#include using namespace std; typedef long long int ll; typedef pair P; typedef vector VI; typedef vector VVI; const ll MOD = 1000000007; const ll INF = (1LL << 30); const ll LINF = (1LL << 62); #define REP(i, n) for(int i = 0; i < n; i++) #define ALL(v) v.begin(), v.end() int main() { int n; cin >> n; vector k(0); string a, b; REP(i, n) { cin >> a >> b; REP(j, k.size()) { if (a == k[j]) k.erase(k.begin() + j); } k.push_back(b); } REP(i, k.size()) cout << k[i] << endl; return 0; }