#include <bits/stdc++.h>
using namespace std;
int main() {
  map<int, int> occ;
  map<int, int> source;
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int s, d;
    cin >> s >> d;
    occ[s] = occ[s] + 1;
    occ[d] = occ[d] + 1;
    source[s] = d;
  }
  int s;
  for (map<int, int>::iterator it = occ.begin(); it != occ.end(); it++) {
    if (it->second == 1 && source.find(it->first) != source.end()) {
      s = it->first;
      break;
    }
  }
  map<int, int>::iterator it;
  int prev = 0;
  for (int i = 0; i < n; i++) {
    cout << s << " ";
    it = source.find(prev);
    prev = s;
    s = it->second;
  }
  cout << endl;
  return 0;
}
