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