#include <bits/stdc++.h>
using namespace std;
int n, a1[200005], a2[200005];
vector<int> ans;
int vis[200005];
void dfs(int i, int nxt, int cnt) {
  if (vis[i]) {
    if (cnt == n) {
      for (int i : ans) cout << i << " ";
      exit(0);
    }
    return;
  }
  vis[i] = 1;
  ans.push_back(i);
  if (a1[i] == nxt or nxt == -1) dfs(a1[i], a2[i], cnt + 1);
  if (a2[i] == nxt or nxt == -1) dfs(a2[i], a1[i], cnt + 1);
  vis[i] = 0;
  ans.pop_back();
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a1[i] >> a2[i];
  dfs(1, -1, 0);
}
