#include <bits/stdc++.h>
using namespace std;
int a[200005];
int b[200005];
int A[200005];
int c[1000003];
int v[1000003];
int V[1000003];
int main() {
  int n, ans1, ans0;
  cin >> n;
  map<int, int> front, back;
  for (int i = 0; i < 1000003; i++) v[i] = 0, V[i] = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
    V[a[i]]++;
    v[b[i]]++;
    c[a[i]] = b[i];
    if (a[i] == 0) ans0 = i;
  }
  for (int i = 0; i < n; i++)
    if (V[a[i]] == 1 && v[a[i]] == 0) ans1 = i;
  A[1] = b[ans0];
  A[0] = a[ans1];
  int index = 1;
  while (index + 2 < n) {
    A[index + 2] = c[A[index]];
    index = index + 2;
  }
  index = 0;
  while (index + 2 < n) {
    A[index + 2] = c[A[index]];
    index = index + 2;
  }
  for (int i = 0; i < n; i++) cout << A[i] << " ";
  return 0;
}
