#include <bits/stdc++.h>
using namespace std;
int N;
int front[1000001];
int back[1000001];
set<int> ids;
int main() {
  scanf("%d", &N);
  for (int i = 0; i <= 1000000; i++) {
    front[i] = back[i] = -1;
  }
  for (int i = 0; i < N; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    back[x] = y;
    front[y] = x;
    ids.insert(x);
    ids.insert(y);
  }
  int firsta;
  int firstb;
  for (set<int>::iterator it = ids.begin(); it != ids.end(); ++it) {
    if (front[*it] == 0) {
      firstb = *it;
    }
    if (front[*it] == -1) {
      firsta = *it;
    }
  }
  while (firsta != -1 && firstb != -1) {
    if (firsta != 0) printf("%d ", firsta);
    if (firstb != 0) printf("%d ", firstb);
    firsta = back[firsta];
    firstb = back[firstb];
  }
  return 0;
}
