#include <bits/stdc++.h>
using namespace std;
struct rc {
  int next, dest;
};
map<long long, int> head;
map<long long, int> mas;
map<long long, bool> used;
rc g[1001000];
int size, n;
long long v;
void add(int a, int b) {
  size++;
  g[size].dest = b;
  g[size].next = head[a];
  head[a] = size;
}
void dfs(int v, int p) {
  cout << v << " ";
  used[v] = 1;
  int step = head[v];
  if (g[step].dest == p) step = g[step].next;
  step = g[step].dest;
  if (step > 0 && !used[step]) dfs(step, v);
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    mas[a]++;
    mas[b]++;
    add(a, b);
    add(b, a);
  }
  v = -1;
  for (map<long long, int>::iterator it = mas.begin(); it != mas.end(); it++) {
    if ((*it).second == 1) {
      v = (*it).first;
      break;
    }
  }
  dfs(v, -1);
  cout << endl;
  return 0;
}
