#include <bits/stdc++.h>
using namespace std;
const long long MAX_SIZE = ((long long)1e6 + 5);
vector<long long> isprime(MAX_SIZE, true);
vector<long long> prime;
vector<long long> SPF(MAX_SIZE);
vector<long long> v[MAX_SIZE];
vector<long long> ans;
long long vis[MAX_SIZE] = {0};
void dfs(long long x) {
  if (!vis[x]) {
    vis[x] = 1;
    if (v[v[x][0]][0] == v[x][1] || v[v[x][0]][1] == v[x][1])
      ans.push_back(x), dfs(v[x][0]);
    else
      ans.push_back(x), dfs(v[x][1]);
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  long long n, x, y;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> x >> y;
    v[i + 1].push_back(x);
    v[i + 1].push_back(y);
  }
  dfs(1);
  for (long long i = 1; i <= n; i++) {
    if (!vis[i]) ans.push_back(i);
  }
  for (auto i : ans) cout << i << " ";
}
