#include <bits/stdc++.h>
using namespace std;
int N, M, T;
int A[1000005], B[1000005];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int i, j, k;
  cin >> N;
  for (i = 0; i <= 1000000; i++) A[i] = -1;
  for (i = 0; i < N; i++) {
    cin >> j >> k;
    A[j] = k;
    B[j]++;
    B[k]++;
  }
  vector<int> v[5];
  k = 0;
  k = A[k];
  while (k > 0) {
    v[0].push_back((k));
    k = A[k];
  }
  for (i = 0; i <= 1000000; i++)
    if (B[i] == 1 && A[i] != -1) k = i;
  while (k > 0) {
    v[1].push_back((k));
    k = A[k];
  }
  k = max(v[1].size(), v[0].size());
  for (i = 0; i < k; i++) {
    if (i < v[1].size()) cout << v[1][i] << ' ';
    if (i < v[0].size()) cout << v[0][i] << ' ';
  }
}
