#include <bits/stdc++.h>
using namespace std;
void weza() {
  std::ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
}
int main() {
  weza();
  long long n, a, b;
  cin >> n;
  vector<int> ans(n + 10);
  vector<int> v(n + 10);
  vector<pair<int, int>> pa(n + 1);
  map<int, bool> mp1;
  map<int, int> mp;
  for (int i = 0; i < n; i++) {
    cin >> a >> b;
    mp[a] = b;
    if (a == 0) ans[1] = b;
    mp1[b] = 1;
    v[i] = a;
  }
  for (int i : v) {
    if (mp1.find(i) == mp1.end()) {
      ans[0] = i;
      break;
    }
  }
  for (int i = 2; i < n; i++) {
    ans[i] = mp[ans[i - 2]];
  }
  for (int i = 0; i < n; i++) {
    cout << ans[i] << " ";
  }
}
