#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  vector<pair<int, int> > v;
  map<int, int> left, right;
  map<int, int>::iterator it;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    if (a == 0) {
      a = -1;
    } else if (b == 0) {
      b = -1;
    }
    left[a] = b;
    right[b] = a;
    v.push_back(make_pair(a, b));
  }
  int a[300000], b, e;
  for (it = left.begin(); it != left.end(); it++) {
    if (!right[it->first]) {
      b = it->first;
    }
    if (it->first == -1) {
      a[1] = left[it->first];
    }
  }
  for (it = right.begin(); it != right.end(); it++) {
    if (!left[it->first]) {
      e = it->first;
    }
    if (it->first == -1) {
      a[n - 1] = right[it->first];
    }
  }
  a[0] = b;
  a[n - 1] = e;
  for (int i = 0; i < n; i++) {
    if (i + 2 < n) {
      a[i + 2] = left[a[i]];
    }
  }
  for (int i = 0; i < n; i++) {
    cout << a[i] << " ";
  }
  cout << endl;
  return 0;
}
