#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  if (!b) return a;
  return gcd(b, a % b);
}
const int MN = 1000111;
int n, a[MN], b[MN], to[MN], vao[MN], res[MN], used[MN];
int main() {
  int n;
  while (cin >> n) {
    memset(to, 0, sizeof to);
    memset(vao, 0, sizeof vao);
    memset(used, 0, sizeof used);
    for (int i = (1); i <= (n); ++i) {
      cin >> a[i] >> b[i];
      if (a[i]) to[a[i]] = i;
      vao[b[i]]++;
    }
    memset(res, 0, sizeof res);
    for (int i = (1); i <= (n); ++i)
      if (a[i] == 0) {
        int u = i;
        for (int x = 1; x <= n; x += 2) {
          res[x + 1] = b[u];
          u = to[b[u]];
        }
      }
    for (int i = (1); i <= (n); ++i)
      if (vao[a[i]] == 0) {
        int u = i;
        for (int x = 1; x <= n; x += 2) {
          if (a[u]) res[x] = a[u];
          if (b[u]) res[x + 2] = b[u];
          u = to[b[u]];
        }
      }
    for (int i = (1); i <= (n); ++i) cout << res[i] << ' ';
    cout << endl;
  }
  return 0;
}
