#include <bits/stdc++.h>
using namespace std;
vector<int> used;
bool same(pair<int, int> a, pair<int, int> b) {
  return (a.first == b.first || a.second == b.first || a.first == b.second ||
          a.second == b.second);
}
int def_next(int v, vector<pair<int, int>> &a) {
  if (same(a[v], a[a[v].first]) && !used[a[v].first]) {
    used[a[v].first] = 1;
    return a[v].first;
  } else {
    used[a[v].second] = 1;
    return a[v].second;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<pair<int, int>> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i].first >> a[i].second;
    a[i].first--;
    a[i].second--;
  }
  int j = 0;
  used.resize(n, 0);
  for (int i = 0; i < n; i++) {
    int x = def_next(j, a);
    cout << x + 1 << ' ';
    j = x;
  }
  return 0;
}
