#include <bits/stdc++.h>
using namespace std;
long long int n, ar[1000005], mark[1000005], ans[1000005];
pair<int, int> p[1000005];
queue<int> que;
int main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> p[i].first >> p[i].second;
  ans[1] = 1;
  mark[1]++;
  int tut1 = p[1].first;
  int tut2 = p[1].second;
  int q, k;
  if (p[tut1].first == tut2 || p[tut1].second == tut2)
    q = tut1, k = tut2;
  else
    q = tut2, k = tut1;
  que.push(q);
  que.push(k);
  int flag = 1;
  while (!que.empty()) {
    int tut = que.front();
    if (mark[tut]) {
      que.pop();
      continue;
    }
    mark[tut]++;
    ans[++flag] = tut;
    que.pop();
    if (!mark[p[tut].first]) que.push(p[tut].first);
    if (!mark[p[tut].second]) que.push(p[tut].second);
  }
  for (int i = 1; i <= n; i++) cout << ans[i] << " ";
}
