#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  map<long long, long long> m1, m2, m3, m4;
  long long arr[n + 10], brr[n];
  vector<long long> v;
  long long x, y;
  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    m1[x] = y;
    m2[y] = x;
    m3[x]++;
    m3[y]++;
  }
  map<long long, long long>::iterator it;
  it = m3.begin();
  while (it->second != 1) {
    it++;
  }
  m4[1] = it->first;
  arr[1] = m1[0];
  arr[n - 2] = m2[0];
  for (int i = 3; i < n; i += 2) {
    arr[i] = m1[arr[i - 2]];
  }
  for (int i = n - 4; i >= 0; i -= 2) {
    arr[i] = m2[arr[i + 2]];
  }
  if (n % 2 == 0) {
    for (int i = 0; i < n; i++) {
      cout << arr[i] << " ";
    }
  } else {
    if (m1[m4[1]] == 0) {
      arr[n - 1] = m4[1];
      for (int i = n - 3; i >= 0; i -= 2) {
        arr[i] = m2[arr[i + 2]];
      }
    } else {
      arr[0] = m4[1];
      for (int i = 2; i < n; i += 2) {
        arr[i] = m1[arr[i - 2]];
      }
    }
    for (int i = 0; i < n; i++) {
      cout << arr[i] << " ";
    }
  }
}
