#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x, y;
  while (cin >> n) {
    map<int, int> parejas;
    vector<int> sol, a(n), b(n);
    for (int i = 0; i < n; i++) {
      cin >> x >> y;
      a[i] = x;
      b[i] = y;
      parejas[x] = y;
    }
    sort(b.begin(), b.end());
    int start = 0;
    for (int i = 0; i < n; i++) {
      if (!binary_search(b.begin(), b.end(), a[i])) {
        start = a[i];
        break;
      }
    }
    cout << start << " " << parejas[0];
    sol.push_back(start);
    sol.push_back(parejas[0]);
    int it = 0;
    while (parejas[sol[it]]) {
      cout << " " << parejas[sol[it++]];
      sol.push_back(parejas[sol[it - 1]]);
    }
    cout << endl;
  }
}
