#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200010;
int n;
int lson[MAXN];
int rson[MAXN];
inline bool hasson(int f, int s) { return ((lson[f] == s) || (rson[f] == s)); }
int main(void) {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", lson + i, rson + i);
  }
  if (n == 3) {
    printf("1 2 3");
    return 0;
  }
  int nowid = 1;
  for (int t = 0; t < n; t++) {
    printf("%d ", nowid);
    if (hasson(lson[nowid], rson[nowid])) {
      nowid = lson[nowid];
    } else {
      nowid = rson[nowid];
    }
  }
  return 0;
}
