#include <bits/stdc++.h>
using namespace std;
using namespace std;
int a[1000010], b[1000010], ans[1000010], vis[1000010], tmp[1000010];
int n;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int fr, ba;
    scanf("%d%d", &fr, &ba);
    a[fr] = ba;
    b[ba] = fr;
    vis[fr] = vis[ba] = 1;
  }
  int k = 2;
  for (int i = a[0]; i; i = a[i], k += 2) {
    ans[k] = i;
    vis[i] = 0;
  }
  for (k = 1;; k++) {
    if (vis[k]) break;
  }
  while (b[k]) {
    k = b[k];
  }
  int fzc = k;
  k = 1;
  for (int i = fzc; i; i = a[i], k += 2) {
    ans[k] = i;
  }
  for (int i = 1; i <= n; i++) printf("%d%s", ans[i], (i == n) ? "\n" : " ");
  return 0;
}
