#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 2e6 + 10;
long long a[MAXN][3], n, x, y;
long long trade[MAXN];
stack<long long> s;
long long next(long long i) {
  long long u = a[i][1], v = a[i][2];
  if (v == a[u][1] || v == a[u][2] && trade[u] == 0) {
    return u;
  } else {
    if (trade[v] == 0) return v;
  }
}
int main() {
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> x >> y;
    a[i][1] = x;
    a[i][2] = y;
  }
  s.push(1);
  cout << 1 << " ";
  while (s.size() < n) {
    long long t = s.top();
    trade[t] = 1;
    a[t][1] = next(t);
    s.push(next(t));
    cout << next(t) << " ";
  }
}
