#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
int main() {
  int n;
  while (scanf("%d", &n) != EOF) {
    map<int, int> ma;
    map<int, int> mb;
    set<int> s;
    set<int>::iterator ps;
    int a, b;
    for (int i = 0; i < n; i++) {
      scanf("%d%d", &a, &b);
      s.insert(a);
      s.insert(b);
      if (ma[a])
        mb[a] = b;
      else
        ma[a] = b;
      if (ma[b])
        mb[b] = a;
      else
        ma[b] = a;
    }
    int sta;
    for (ps = s.begin(); ps != s.end(); ps++) {
      if (mb[*ps] == 0) {
        sta = *ps;
        break;
      }
    }
    printf("%d ", sta);
    int pre = sta;
    int next = ma[sta];
    if (next == 0) {
      printf("\n");
      continue;
    }
    while (1) {
      printf("%d ", next);
      if (ma[next] == pre) {
        pre = next;
        next = mb[next];
        if (next == 0) break;
      } else {
        pre = next;
        next = ma[next];
        if (next == 0) break;
      }
    }
    printf("\n");
  }
  return 0;
}
