#include <bits/stdc++.h>
int n;
std::vector<std::pair<int, int> > A;
std::vector<int> next;
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);
  std::cin >> n;
  if (n == 3) {
    std::cout << "1 2 3"
              << "\n";
    return 0;
  }
  next.resize(n);
  for (int i = 0; i < (n); ++i) {
    int a, b;
    std::cin >> a >> b;
    a--;
    b--;
    A.push_back(std::make_pair(a, b));
  }
  for (int i = 0; i < (n); ++i) {
    next[i] = A[i].first;
    if (A[A[i].first].first != A[i].second &&
        A[A[i].first].second != A[i].second)
      next[i] = A[i].second;
  }
  std::vector<int> xd;
  xd.push_back(0);
  while ((int)(xd).size() < n) xd.push_back(next[xd.back()]);
  for (auto &i : xd) std::cout << i + 1 << " ";
  return 0;
}
