#include <bits/stdc++.h>
using namespace std;
map<int, int> city;
int g[100005][5], len[100005], color[100005], node[100005];
void dfs(int u) {
  int i, v, r;
  color[u] = 1;
  for (i = 1; i <= len[u]; i++) {
    v = g[u][i];
    if (color[v] == 0) {
      printf(" %d", node[v]);
      dfs(v);
    }
  }
}
int main() {
  int i, n, u, v, U, V, k;
  while (scanf("%d", &n) == 1) {
    city.clear();
    memset(len, 0, sizeof(len));
    memset(node, 0, sizeof(node));
    memset(color, 0, sizeof(color));
    memset(g, 0, sizeof(g));
    for (i = 1, k = 1; i <= n; i++) {
      scanf("%d%d", &U, &V);
      if (city.find(U) != city.end())
        u = city[U];
      else
        u = city[U] = k++;
      node[u] = U;
      if (city.find(V) != city.end())
        v = city[V];
      else
        v = city[V] = k++;
      node[v] = V;
      g[u][++len[u]] = v;
      g[v][++len[v]] = u;
    }
    for (i = 1; i <= n; i++) {
      if (len[i] == 1) break;
    }
    printf("%d", node[i]);
    dfs(i);
    printf("\n");
  }
  return 0;
}
