#include <bits/stdc++.h>
#pragma clang diagnostic push
#pragma ide diagnostic ignored "cert-err34-c"
const long long mod = (long long)1000000007;
using namespace std;
long long power(long long x, long long y) {
  long long ans = 1;
  x %= mod;
  while (y) {
    if (y & 1) ans *= x;
    x *= x;
    x %= mod;
    ans %= mod;
    y >>= 1;
  }
  return ans;
}
int a[2 * 100001][2];
int ne[2 * 100001];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr), cout.tie(nullptr);
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d%d", &a[i][0], &a[i][1]);
  for (int i = 1; i <= n; i++) {
    if (a[a[i][0]][0] == a[i][1] || a[a[i][0]][1] == a[i][1])
      ne[i] = a[i][0];
    else
      ne[i] = a[i][1];
  }
  if (n == 3)
    printf("1 2 3");
  else {
    printf("1 ");
    int c = ne[1];
    while (c != 1) {
      printf("%d ", c);
      c = ne[c];
    }
  }
}
#pragma clang diagnostic pop
