#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, x[200004], y[200005], i, tp, jp;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> x[i] >> y[i];
  }
  long long int j = 1;
  if (n == 3) {
    cout << "1 2 3" << endl;
    return 0;
  }
  for (i = 1; i <= n; i++) {
    cout << j << " ";
    tp = x[j];
    jp = y[j];
    if (x[tp] == jp || y[tp] == jp)
      j = tp;
    else
      j = jp;
  }
}
