#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  int size_ = 1e6 + 1;
  vector<int> aa(size_, 0), bb(size_, 0);
  vector<int> cnta(size_, 0), cntb(size_, 0);
  cin >> n;
  vector<int> x(n + 1, 0);
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    if (a == 0 && b) {
      x[1] = b;
    } else if (a && b == 0) {
      x[n - 2] = a;
    }
    aa[b] = a;
    bb[a] = b;
    cnta[a]++;
    cntb[b]++;
  }
  int first = 0, last = 0;
  for (int i = 1; i <= size_; i++) {
    if (cnta[i] == 1 && cntb[i] == 0) {
      first = i;
    }
    if (cntb[i] == 1 && cnta[i] == 0) {
      last = i;
    }
  }
  x[0] = first;
  x[n - 1] = last;
  for (int i = 0; i <= n - 2; i += 2) {
    x[i + 2] = bb[first];
    first = bb[first];
  }
  for (int i = n - 1; i >= 2; i -= 2) {
    x[i - 2] = aa[last];
    last = aa[last];
  }
  first = x[1];
  last = x[n - 1];
  for (int i = 1; i <= n - 2; i += 2) {
    if (x[i + 2] == 0) {
      x[i + 2] = bb[first];
      first = bb[first];
    }
  }
  for (int i = n - 2; i >= 2; i -= 2) {
    if (x[i - 2] == 0) {
      x[i - 2] = aa[last];
      last = aa[last];
    }
  }
  for (int i = 0; i < n; i++) {
    cout << x[i] << ' ';
  }
}
