#include <bits/stdc++.h>
using namespace std;
bool compare(string &s1, string &s2) { return s1.size() < s2.size(); }
bool sortmahstyle(const pair<int, int> &a, const pair<int, int> &b) {
  if (a.first < b.first) return true;
  return false;
}
long long int const maxm = 1e6;
long long int const minm = -1e9;
void solve() {
  int n;
  cin >> n;
  int next[n + 1][2];
  for (int i = 1; i <= n; i++) cin >> next[i][0] >> next[i][1];
  vector<int> ans;
  ans.push_back(3);
  while (ans.size() < n) {
    int cur = ans.back();
    if (next[next[cur][0]][0] == next[cur][1] ||
        next[next[cur][0]][1] == next[cur][1]) {
      ans.push_back(next[cur][0]);
      ans.push_back(next[cur][1]);
    } else {
      ans.push_back(next[cur][1]);
      ans.push_back(next[cur][0]);
    }
  }
  for (int i = 0; i < n; i++) cout << ans[i] << " ";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int t = 1;
  while (t-- > 0) solve();
  return 0;
}
