#include <bits/stdc++.h>
using namespace std;
const int MaxN = 100005;
struct Edge {
  int v;
  Edge *nxt;
} buf[MaxN * 2], *g[MaxN], *p;
void add(int u, int v) {
  p->v = v;
  p->nxt = g[u];
  g[u] = p++;
}
map<int, int> mp;
int a[MaxN], in[MaxN];
int ax[MaxN];
void dfs(int u, int pre, int pos) {
  ax[pos++] = u;
  for (Edge *i = g[u]; i; i = i->nxt)
    if (i->v != pre) {
      dfs(i->v, u, pos);
    }
}
int main() {
  p = buf;
  memset(g, 0, sizeof(g));
  int n;
  scanf("%d", &n);
  mp.clear();
  int N = 0;
  for (int i = 0; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    if (mp.find(x) == mp.end()) {
      mp[x] = N;
      a[N] = x;
      x = N++;
    } else
      x = mp[x];
    if (mp.find(y) == mp.end()) {
      mp[y] = N;
      a[N] = y;
      y = N++;
    } else
      y = mp[y];
    add(x, y);
    add(y, x);
    in[x]++;
    in[y]++;
  }
  for (int i = 0; i < N; i++)
    if (in[i] == 1) dfs(i, -1, 0);
  for (int i = 0; i <= n; i++) printf("%d%c", a[ax[i]], i == n ? '\n' : ' ');
  return 0;
}
