#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> data1(2000001, -1), data2(1000001, -1);
  int n, j, k;
  scanf("%d", &n);
  int a[n], b[n], hsl[n];
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &a[i], &b[i]);
    data1[a[i]] = b[i];
    data2[b[i]] = a[i];
  }
  for (int i = 0; i < n; i++) {
    if (data2[a[i]] == -1) {
      hsl[0] = a[i];
      break;
    }
  }
  j = hsl[0];
  k = 2;
  while (data1[j] != 0 && data1[j] != -1) {
    hsl[k] = data1[j];
    j = data1[j];
    k += 2;
  }
  j = 0;
  k = 1;
  while (data1[j] != 0 && data1[j] != -1) {
    hsl[k] = data1[j];
    j = data1[j];
    k += 2;
  }
  for (int i = 0; i < n; i++) {
    printf("%d ", hsl[i]);
  }
  printf("\n");
  return 0;
}
