#include <bits/stdc++.h>
using namespace std;
vector<int> e[200005], E[200005], v;
int vis[200005];
inline void dfs(int u) {
  if (vis[u]) return;
  vis[u] = 1;
  v.push_back(u);
  int x = E[u][0], y = E[u][1];
  if (e[x][0] == e[u][0] || e[x][0] == e[u][1] || e[x][1] == e[u][1] ||
      e[x][1] == e[u][0])
    dfs(x);
  dfs(y);
}
int main(int argc, char** argv) {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x, y;
    cin >> x >> y;
    e[i].push_back(y);
    e[i].push_back(x);
    E[x].push_back(i);
    E[y].push_back(i);
  }
  dfs(1);
  for (int i = v.size() - 1; i >= 0; i--) cout << v[i] << " ";
  return 0;
}
