#include <bits/stdc++.h>
using namespace std;
long long int mod1 = 998244353;
long long int mod = 1e9 + 7;
bool comp(long long int x, long long int y) {
  if (x > y) return true;
  return false;
}
long long int INF = 1e18;
pair<long long int, long long int> a[300005];
long long int vis[300005];
void solve() {
  long long int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i].first >> a[i].second;
  cout << 1 << " ";
  int i = 1;
  vis[1] = 1;
  for (int j = 1; j < n; ++j) {
    if (vis[a[i].first] == 0 && (a[a[i].first].first == a[i].second ||
                                 a[a[i].first].second == a[i].second)) {
      cout << a[i].first << " ";
      i = a[i].first;
      vis[i] = 1;
    } else {
      cout << a[i].second << " ";
      i = a[i].second;
      vis[i] = 1;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t = 1;
  while (t--) {
    solve();
    cout << "\n";
  }
  return 0;
}
