#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void ZZ(const char* name, Arg1&& arg1) {
  std::cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  std::cerr.write(names, comma - names) << " = " << arg1;
  ZZ(comma, args...);
}
int n, u, v;
int nxt[1000010], ans[1000010], cnt[1000010];
pair<int, int> a[1000000];
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i].first >> a[i].second;
    cnt[a[i].second] = 1;
    nxt[a[i].first] = a[i].second;
    if (!a[i].first) u = a[i].second;
  }
  for (int i = 0; i < n; i++) {
    if (!cnt[a[i].first]) {
      v = a[i].first;
      break;
    }
  }
  for (int i = 0; i < n; i += 2) {
    ans[i] = v;
    v = nxt[v];
  }
  for (int i = 1; i < n; i += 2) {
    ans[i] = u;
    u = nxt[u];
  }
  for (int i = 0; i < n; i++) cout << ans[i] << ' ';
  return 0;
}
