#include <bits/stdc++.h>
using namespace std;
int n;
int g[222222];
vector<int> lst[222222];
int a[222222], b[222222], used[222222];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x, y;
    cin >> x >> y;
    a[i] = x;
    b[i] = y;
  }
  int x = a[1], y = b[1];
  vector<int> v;
  set<int> s;
  for (int j = 0; j <= 1; j++) {
    int cur = x, next = y;
    if (j == 1) swap(cur, next);
    int t = 0;
    for (int kk = 1; kk <= n; kk++) {
      s.insert(cur);
      if (s.size() == n) break;
      v.push_back(cur);
      if (next == a[cur]) {
        int cc = cur;
        cur = next;
        next = b[cc];
      } else if (next == b[cur]) {
        int cc = cur;
        cur = next;
        next = a[cc];
      } else {
        t = 1;
        break;
      }
    }
    v.push_back(cur);
    memset(used, 0, sizeof used);
    s.clear();
    if (!t) {
      break;
    }
    v.clear();
  }
  for (int i = 0; i < n; i++) cout << v[i] << ' ';
}
