#include <bits/stdc++.h>
using namespace std;
bool usado[200010];
vector<int> vet;
vector<int> adj[200010];
int n;
bool fb(int v, int p, int k) {
  usado[v] = true;
  vet.push_back(v);
  if (k == n - 1) return p == 1;
  bool res = false;
  if (adj[v][0] == p) {
    res |= fb(adj[v][0], adj[v][1], k + 1);
  }
  if ((!res) and (adj[v][1] == p)) {
    res |= fb(adj[v][1], adj[v][0], k + 1);
  }
  usado[v] = false;
  if (!res) vet.pop_back();
  return res;
}
int main() {
  cin.tie(0);
  cin.sync_with_stdio(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int a, b;
    cin >> a >> b;
    adj[i].push_back(a);
    adj[i].push_back(b);
  }
  vet.push_back(1);
  if (!fb(adj[1][0], adj[1][1], 1)) {
    fb(adj[1][1], adj[1][0], 1);
  }
  for (int i = 0; i < n - 1; i++) cout << vet[i] << " ";
  cout << vet[n - 1] << '\n';
  return 0;
}
