#include <bits/stdc++.h>
using namespace std;
int n;
bool isend[1000005];
unordered_set<int> has;
int nxt[1000005];
int ans[200005];
int main() {
  scanf("%d", &n);
  int a, b;
  int start = -1, start2 = -1;
  memset(isend, false, sizeof(isend));
  memset(nxt, -1, sizeof(nxt));
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", &a, &b);
    has.insert(a);
    has.insert(b);
    nxt[a] = b;
    isend[b] = true;
    if (a == 0) start2 = b;
  }
  int p, e;
  p = 2;
  e = start2;
  while (p <= n) {
    ans[p] = e;
    e = nxt[e];
    p += 2;
  }
  for (int i = 1; i <= 1000000; ++i) {
    if (has.find(i) != has.end() && !isend[i] && i != start2) {
      start = i;
      break;
    }
  }
  p = 1;
  e = start;
  while (p <= n) {
    ans[p] = e;
    e = nxt[e];
    p += 2;
  }
  for (int i = 1; i <= n; ++i) {
    printf("%d", ans[i]);
    if (i != n)
      printf(" ");
    else
      printf("\n");
  }
  return 0;
}
