#include <bits/stdc++.h>
using namespace std;
const int N = (int)1e6 + 10;
int n;
pair<int, int> a[N];
vector<int> ans;
bool visited[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n;
  ans.push_back(1);
  for (int i = 1; i <= n; i++) cin >> a[i].first >> a[i].second;
  if (n == 3) {
    cout << 1 << ' ' << 3 << ' ' << 2;
    return 0;
  }
  int now = 1;
  while (!visited[now]) {
    visited[now] = true;
    pair<int, int> tmp = a[a[now].first];
    if (tmp.first == a[now].second || tmp.second == a[now].second) {
      ans.push_back(a[now].first);
      now = a[now].first;
      continue;
    }
    tmp = a[a[now].second];
    if (tmp.first == a[now].first || tmp.second == a[now].first) {
      ans.push_back(a[now].second);
      now = a[now].second;
    }
  }
  for (int i = 0; i < n; i++) cout << ans[i] << ' ';
  return 0;
}
