#include <bits/stdc++.h>
using namespace std;
int n = 0;
map<int, int> num1;
map<int, int> num2;
set<int> num3;
int ans[100010];
int anst[200010];
int main() {
  scanf("%d", &n);
  int temp1, temp2;
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &temp1, &temp2);
    num1[temp1] = temp2;
    num2[temp2] = temp1;
    num3.insert(temp1);
    num3.insert(temp2);
  }
  ans[0] = 0;
  int temp = 0;
  num3.erase(0);
  for (int i = 0; i < n / 2; i++) {
    ans[i] = num1[temp];
    temp = ans[i];
    num3.erase(temp);
  }
  temp = *num3.begin();
  int cnt = n / 2 + 1;
  anst[cnt] = temp;
  cnt++;
  while (num1[temp] != 0) {
    temp = num1[temp];
    anst[cnt] = temp;
    cnt++;
  }
  cnt = n / 2;
  temp = *num3.begin();
  while (num2[temp] != 0) {
    temp = num2[temp];
    anst[cnt] = temp;
    cnt--;
  }
  printf("%d", anst[cnt + 1]);
  for (int i = 0; i < (n / 2 - 1); i++) {
    printf(" %d", ans[i]);
    printf(" %d", anst[cnt + 2 + i]);
  }
  printf(" %d", ans[n / 2 - 1]);
  if (n & 1) {
    printf(" %d", anst[cnt + 1 + n / 2]);
  }
  printf("\n");
  return 0;
}
