#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  map<int, int> aMap;
  map<int, int> bMap;
  for (int i = 0; i < n; i++) {
    int ai, bi;
    cin >> ai >> bi;
    bMap.insert(make_pair(ai, bi));
    aMap.insert(make_pair(bi, ai));
  }
  vector<int> seq(n);
  int index = 1;
  int A = 0;
  while (index < n) {
    seq[index] = bMap[A];
    A = bMap[A];
    index += 2;
  }
  map<int, int>::iterator it;
  for (it = bMap.begin(); it != bMap.end(); it++) {
    if (aMap.find(it->first) == aMap.end()) break;
  }
  (seq[0] = it->first, index = 2, A = seq[0]);
  while (index < n) {
    seq[index] = bMap[A];
    A = bMap[A];
    index += 2;
  }
  for (int i = 0; i < n; i++) cout << seq[i] << " ";
  return 0;
}
