#include <bits/stdc++.h>
using namespace std;
void inout() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
}
int main() {
  inout();
  long long n, i, u, v;
  cin >> n;
  map<long long, long long> prv, nxt, cnt1, cnt2;
  vector<long long> ans(n + 5);
  for (i = 0; i < n; i++) {
    cin >> u >> v;
    prv[v] = u;
    nxt[u] = v;
    cnt1[u]++;
    cnt2[v]++;
  }
  for (auto k : cnt1)
    if (cnt1[k.first] > cnt2[k.first]) ans[1] = k.first;
  for (auto k : cnt2)
    if (cnt1[k.first] < cnt2[k.first]) ans[n] = k.first;
  i = 3;
  while (i <= n) {
    ans[i] = nxt[ans[i - 2]];
    i += 2;
  }
  i = n + n % 2 - 2;
  while (i > 0) {
    ans[i] = prv[ans[i + 2]];
    i -= 2;
  }
  for (i = 1; i <= n; i++) cout << ans[i] << " ";
  return 0;
}
