#include <bits/stdc++.h>
using namespace std;
int l[1000005], r[1000005], g[1000005], arr[1000005], n, a, b, srt, snd;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a >> b;
    l[a] = 1;
    r[b] = 1;
    g[a] = b;
    if (a == 0) snd = b;
  }
  for (int i = 1; i <= 1000000; i++) {
    if (l[i] == 1 && r[i] == 0) {
      srt = i;
      break;
    }
  }
  int i;
  i = 1;
  while (srt != 0) {
    arr[i] = srt;
    srt = g[srt];
    i += 2;
  }
  i = 2;
  while (snd != 0) {
    arr[i] = snd;
    snd = g[snd];
    i += 2;
  }
  for (i = 1; i <= n; i++) cout << arr[i] << " ";
  cout << endl;
  return 0;
}
