#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int g[N][2];
vector<int> ans;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ans.push_back(-1);
  ans.push_back(1);
  int n;
  cin >> n;
  int cur = 1;
  for (int i = 1; i <= n; i++) {
    int x, y;
    cin >> x >> y;
    g[i][0] = x;
    g[i][1] = y;
  }
  while (ans.size() < n + 1) {
    if (cur == 1) {
      int x = g[ans[cur]][0], y = g[ans[cur]][1];
      if (g[x][0] == y || g[x][1] == y) {
        ans.push_back(x);
        ans.push_back(y);
      } else {
        ans.push_back(y);
        ans.push_back(x);
      }
      cur++;
    } else {
      int x = ans[cur], y = ans[cur + 1];
      if (g[x][0] == y)
        ans.push_back(g[x][1]);
      else
        ans.push_back(g[x][0]);
      cur++;
    }
  }
  for (int i = 1; i < ans.size(); i++) cout << ans[i] << " ";
  return 0;
}
