#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int n;
int p[N];
pair<int, int> v[N];
void solve(int nx, int nnx) {
  int curr = 1;
  for (int i = 1; i <= n; i++) p[i] = 0;
  p[curr] = nx;
  p[nx] = nnx;
  curr = nx;
  bool okay = true;
  for (int i = 2; i <= n; i++) {
    if (v[curr].first == nnx) {
      if (!p[nnx]) p[nnx] = v[curr].second;
      nx = nnx;
      nnx = v[curr].second;
      curr = nx;
    } else if (v[curr].second == nnx) {
      if (!p[nnx]) p[nnx] = v[curr].first;
      nx = nnx;
      nnx = v[curr].first;
      curr = nx;
    } else {
      okay = false;
      break;
    }
  }
  curr = 1;
  for (int i = 1; i <= n; i++) {
    curr = p[curr];
  }
  if (curr != 1) okay = false;
  if (okay) {
    curr = 1;
    for (int i = 1; i <= n; i++) {
      printf("%d ", curr);
      curr = p[curr];
    }
    exit(0);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    v[i].first = x;
    v[i].second = y;
  }
  solve(v[1].first, v[1].second);
  solve(v[1].second, v[1].first);
  return 0;
}
