#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  long long n;
  cin >> n;
  map<long long, long long> m;
  set<long long> s;
  for (long long i = 0; i < n; i++) {
    long long f, b;
    cin >> f >> b;
    m[f] = b;
    s.insert(b);
  }
  long long f;
  vector<long long> ans;
  for (auto i : m) {
    if (s.find(i.first) == s.end()) {
      ans.push_back(i.first);
      break;
    }
  }
  ans.push_back(m[0]);
  long long ind = 0;
  while (ans.size() < n) {
    ans.push_back(m[ans[ind++]]);
  }
  for (auto i : ans) cout << i << " ";
  cout << endl;
  return 0;
}
