#include <bits/stdc++.h>
using namespace std;
const int M = 2e5 + 5;
int n, a[M], b[M], ans[M];
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i] >> b[i];
  for (int i = 1; i <= n; i++) {
    int next, nextNext;
    if (!ans[i]) {
      ans[i] = i;
      next = a[i];
      nextNext = b[i];
    } else {
      next = a[ans[i]];
      nextNext = b[ans[i]];
    }
    if (a[next] != nextNext && b[next] != nextNext) swap(next, nextNext);
    if (!ans[i + 1] && i + 1 <= n) ans[i + 1] = next;
    if (!ans[i + 2] && i + 2 <= n) ans[i + 2] = nextNext;
  }
  for (int i = 1; i <= n; i++) cout << ans[i] << " ";
  return 0;
}
