#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  long int a[n][2];
  for (long int i = 0; i < n; i++) {
    cin >> a[i][0] >> a[i][1];
  }
  long int m1 = a[0][0], m2 = a[0][1], cur, b[n], l = 0;
  cur = 1;
  for (long int i = 1; i <= n; i++) {
    long int t = a[cur - 1][1];
    if (a[cur - 1][0] == a[t - 1][0] || a[cur - 1][0] == a[t - 1][1]) {
      b[l] = t;
      cur = t;
      l++;
    } else {
      b[l] = a[cur - 1][0];
      cur = a[cur - 1][0];
      l++;
    }
  }
  if (n == 3) {
    cout << "1 2 3";
  } else
    for (long int i = 0; i < n; i++) {
      cout << b[i] << " ";
    }
  return 0;
}
