#include <bits/stdc++.h>
using namespace std;
struct Node {
  int a, b;
} f[1100009];
int nn;
int n[1100009];
int out[1100009];
int ans[1100009];
int main() {
  scanf("%d", &nn);
  memset(n, -1, sizeof n);
  memset(out, 0, sizeof out);
  for (int i = 0; i < nn; i++) {
    scanf("%d%d", &f[i].a, &f[i].b);
    n[f[i].a] = f[i].b;
    out[f[i].b]++;
  }
  int cnt = 1;
  for (int i = 0; i != -1; i = n[i]) {
    if (cnt != 1 && i == 0) break;
    ans[cnt] = n[i];
    cnt += 2;
  }
  int p;
  for (int i = 0; i < nn; i++) {
    if (out[f[i].a] == 0) {
      p = f[i].a;
      break;
    }
  }
  ans[0] = p;
  cnt = 2;
  for (int i = p; i != -1; i = n[i]) {
    ans[cnt] = n[i];
    cnt += 2;
  }
  for (int i = 0; i < nn; i++) cout << ans[i] << " ";
  return 0;
}
