#include <bits/stdc++.h>
inline long read() {
  long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
using namespace std;
map<int, int> cnt;
int main() {
  int i = 0, j, k;
  int n, m;
  int fi, se;
  int city, f_num, s_num;
  cin >> n;
  pair<int, int> patt[n + 1];
  map<int, int> nxt;
  for (i = 0; i < n; i++) {
    cin >> fi >> se;
    nxt[fi] = se;
    ++cnt[fi];
    --cnt[se];
    if (fi == 0) {
      f_num = se;
    }
    if (se == 0) {
      s_num = fi;
    }
  }
  int arr[n + 2];
  arr[0] = arr[n + 1] = 0;
  for (i = 1; i <= n; i++) {
    arr[i] = -1;
  }
  for (auto cur : cnt) {
    if (cur.second == 1) {
      city = cur.first;
      break;
    }
  }
  arr[1] = city;
  j = 3;
  while (nxt[city] != 0) {
    arr[j] = nxt[city];
    j += 2;
    city = nxt[city];
  }
  {
    k = 2;
    arr[k] = f_num;
    k += 2;
    city = f_num;
    while ((nxt.find(city) != nxt.end()) && nxt[city] != 0) {
      arr[k] = nxt[city];
      k += 2;
      city = nxt[city];
    }
  }
  for (i = 1; i <= n; i++) {
    cout << arr[i] << " ";
  }
  return 0;
}
