#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000000 + 10;
vector<int> G[maxn], S[maxn];
void init() {
  for (int i = 0; i < maxn; i++) G[i].clear(), S[i].clear();
}
int a[maxn];
int n, x, y;
void solve1() {
  init();
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &x, &y);
    G[x].push_back(y);
    S[y].push_back(x);
  }
  int u = 0;
  int tp = G[u].size();
  int m = n - 1;
  while (tp) {
    u = S[u][0];
    a[m] = u;
    m -= 2;
    tp = S[u].size();
  }
  u = 0;
  tp = G[u].size();
  m = 2;
  while (tp) {
    u = G[u][0];
    a[m] = u;
    tp = G[u].size();
    m += 2;
  }
  for (int i = 1; i <= n; i++) {
    if (i == 1)
      printf("%d", a[i]);
    else
      printf(" %d", a[i]);
  }
  printf("\n");
}
int main() {
  while (scanf("%d", &n) != EOF) {
    if (n % 2 == 0) {
      solve1();
      continue;
    }
    init();
    bool vis[maxn], vv[maxn];
    memset(vis, 0, sizeof(vis));
    memset(vv, 0, sizeof(vv));
    for (int i = 1; i <= n; i++) {
      scanf("%d%d", &x, &y);
      G[x].push_back(y);
      vis[x] = 1;
      vis[y] = 1;
      vv[y] = 1;
    }
    int t;
    for (int i = 1; i < maxn; i++) {
      if (vis[i] && !vv[i]) {
        t = i;
        break;
      }
    }
    int u = 0;
    int tp = G[u].size();
    int v = G[u][0];
    int m = 2;
    while (v) {
      u = G[u][0];
      a[m] = u;
      m += 2;
      tp = G[u].size();
      v = G[u][0];
    }
    u = t;
    a[1] = t;
    tp = G[u].size();
    m = 3;
    while (tp) {
      u = G[u][0];
      a[m] = u;
      m += 2;
      tp = G[u].size();
    }
    for (int i = 1; i <= n; i++) {
      if (i == 1)
        printf("%d", a[i]);
      else
        printf(" %d", a[i]);
    }
    printf("\n");
  }
  return 0;
}
