#include <bits/stdc++.h>
using namespace std;
int ans[2 * 1000000 + 10];
int net[2 * 1000000 + 10];
int vis[2 * 1000000 + 10];
int g[2 * 1000000 + 10];
int main() {
  int n;
  while (~scanf("%d", &n)) {
    memset(ans, -1, sizeof(ans));
    memset(net, -1, sizeof(net));
    memset(vis, 0, sizeof(vis));
    int u, v;
    int cnt = 0;
    for (int i = 0; i < n; i++) {
      scanf("%d%d", &u, &v);
      net[u] = v;
      if (!vis[u]) g[cnt++] = u;
      if (!vis[v]) g[cnt++] = v;
      vis[u]++;
      vis[v]++;
      if (!u) ans[2] = v;
    }
    for (int i = 0; i < cnt; i++) {
      if (vis[g[i]] == 1 && net[g[i]] != -1) {
        ans[1] = g[i];
        break;
      }
    }
    for (int i = 1; i < cnt; i++) {
      ans[i + 2] = net[ans[i]];
      ans[i + 3] = net[ans[i + 1]];
    }
    for (int i = 1; i < cnt; i++) {
      if (i > 1) printf(" ");
      printf("%d", ans[i]);
    }
    printf("\n");
  }
  return 0;
}
