#include <bits/stdc++.h>
using namespace std;
int a[1000001], b[1000001], c[1000001];
int main() {
  int n;
  cin >> n;
  int p, q;
  int m[n];
  map<int, int> mp;
  for (int i = 0; i < n; i++) {
    cin >> p >> q;
    c[p] = q;
    if (p == 0) {
      m[1] = q;
    }
    mp[p] = q;
    b[p]++;
    b[q]++;
  }
  for (auto x : mp) {
    if (b[x.first] == 1) {
      m[0] = x.first;
    }
  }
  for (int i = 2; i < n; i++) {
    m[i] = c[m[i - 2]];
  }
  for (int i = 0; i < n; i++) cout << m[i] << " ";
}
