#include <bits/stdc++.h>
using namespace std;
const int base = 1000000000;
const int base_digits = 9;
int hashe[1000001] = {-1}, bhashe[1000001] = {-1};
int a, b;
int main() {
  int n;
  cin >> n;
  memset(hashe, -1, sizeof(hashe));
  memset(bhashe, -1, sizeof(bhashe));
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &a, &b);
    hashe[a] = b;
    bhashe[b] = a;
  }
  int start = 0;
  for (int i = 1; i <= 1000000; i++) {
    if (hashe[i] != -1 && bhashe[i] == -1) {
      start = i;
      break;
    }
  }
  printf("%d ", start);
  int done = 1, q = 0;
  while (done < n) {
    if (done % 2 == 1) {
      printf("%d ", hashe[q]);
      q = hashe[q];
    } else {
      printf("%d ", hashe[start]);
      start = hashe[start];
    }
    done++;
  }
  return 0;
}
