#include <bits/stdc++.h>
using namespace std;
typedef struct {
  int x, y;
} Kid;
int main() {
  int n;
  cin >> n;
  Kid a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i].x >> a[i].y;
  }
  int ans[n];
  int flag[n];
  for (int i = 0; i < n; i++) {
    flag[i] = 0;
  }
  for (int i = 0, x = 1; i < n; i++) {
    cout << x << " ";
    flag[x - 1] = 1;
    int first = a[x - 1].x, end = a[x - 1].y;
    if (end != a[first - 1].x && end != a[first - 1].y) swap(first, end);
    if (flag[first - 1]) {
      swap(first, end);
    }
    x = first;
  }
}
