#include <bits/stdc++.h>
using namespace std;
vector<int> a;
int m[4], b[2000002][4], c[2000002], e[2000002], d[2000002], g[20000002];
int main() {
  long long n = 0, r = 0, s = 0, k;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> b[i][0] >> b[i][1];
    if (b[i][0] == 0) s = (i);
    e[i] = b[i][0];
    d[i] = b[i][1];
    c[b[i][0]] = i;
  }
  sort(e, e + n);
  sort(d, d + n);
  for (int i = 0; i < n; i++) {
    if (e[i] != d[i]) {
      if (e[i] != d[i + 1]) {
        k = e[i];
        break;
      }
    }
  }
  cout << k << " " << b[s][1] << " ";
  g[0] = k;
  g[1] = b[s][1];
  for (int i = 2; i < n; i++) {
    g[i] = b[c[g[i - 2]]][1];
    cout << g[i] << " ";
  }
  return 0;
}
