#include <bits/stdc++.h>
int inp[2000001], cnt[2000001], ans[300001];
int main() {
  int n, i, a, b, tmp, idx;
  scanf("%d", &n);
  for (i = 0; i < n; ++i) {
    scanf("%d %d", &a, &b);
    inp[a] = b;
    cnt[a]++;
    cnt[b]++;
  }
  tmp = 0;
  idx = 1;
  while (inp[tmp] != 0) {
    cnt[tmp]--;
    cnt[inp[tmp]]--;
    ans[idx] = inp[tmp];
    tmp = inp[tmp];
    idx += 2;
  }
  for (i = 1; i <= 1000000; ++i)
    if (cnt[i] == 1 && inp[i] != 0) break;
  if (i == 1000001) {
    for (i = 1; i <= 1000000; ++i)
      if (cnt[i] == 1) break;
  }
  tmp = i;
  idx = 2;
  ans[0] = tmp;
  while (inp[tmp] != 0) {
    ans[idx] = inp[tmp];
    tmp = inp[tmp];
    idx += 2;
  }
  for (i = 0; i < n; ++i) {
    printf("%d ", ans[i]);
  }
  return 0;
}
