#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(NULL);
  cout.tie(NULL);
  cin.tie(NULL);
  long long n, i, j, a1, a2;
  cin >> n;
  vector<pair<long long, long long>> a;
  vector<long long> b;
  for (i = 1; i <= n; ++i) {
    cin >> a1 >> a2;
    a.push_back(make_pair(a1, a2));
  }
  b.push_back(1);
  for (i = 1, j = 0; i < n; i += 2) {
    pair<long long, long long> a1 = a[j];
    pair<long long, long long> a2 = a[a1.first - 1];
    if (a2.first == a1.second || a2.second == a1.second) {
      b.push_back(a1.first);
      b.push_back(a1.second);
      j = a1.second - 1;
    } else {
      b.push_back(a1.second);
      b.push_back(a1.first);
      j = a1.first - 1;
    }
  }
  for (i = 0; i < n; ++i) {
    cout << b[i] << " ";
  }
  cout << "\n";
  return 0;
}
