#include <bits/stdc++.h>
using namespace std;
const bool db = false;
map<int, int> up, dw, cnt, cnt2;
set<int> us;
int a[400010], b[400010], n, ans[400010];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d%d", &a[i], &b[i]);
    up[a[i]] = b[i];
    dw[b[i]] = a[i];
  }
  int cur = 0, pos = 0;
  while (pos <= n) {
    ans[pos] = cur;
    cur = up[cur];
    us.insert(ans[pos]);
    pos += 2;
  }
  us.insert(0);
  if (n % 2 == 0) {
    cur = 0, pos = n + 1;
    while (pos > 0) {
      ans[pos] = cur;
      cur = dw[cur];
      pos -= 2;
    }
  } else {
    int l = n, cur;
    for (int i = 1; i <= n; ++i)
      if (us.find(a[i]) == us.end()) {
        ++cnt[a[i]];
        ++cnt2[b[i]];
        cnt2[a[i]];
        cnt[b[i]];
      }
    for (map<int, int>::iterator it = cnt2.begin(); it != cnt2.end(); ++it)
      if (it->second == 1 && cnt[it->first] == 0) {
        cur = it->first;
        break;
      }
    while (l > 0) {
      ans[l] = cur;
      cur = dw[cur];
      l -= 2;
    }
  }
  for (int i = 1; i <= n; ++i) cout << ans[i] << (i == n ? "\n" : " ");
  getchar();
  getchar();
  return 0;
}
