#include <bits/stdc++.h>
using namespace std;
using std::string;
map<pair<int, int>, int> M;
int a[2 * 100002], b[2 * 100002];
vector<int> ans;
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
    M[make_pair(a[i], b[i])] = i + 1;
    M[make_pair(b[i], a[i])] = i + 1;
  }
  auto it1 = M.find(make_pair(1, a[0]));
  auto it2 = M.find(make_pair(1, b[0]));
  if (it1 != M.end())
    ans.push_back(a[0]);
  else
    ans.push_back(b[0]);
  ans.push_back(1);
  if (it1 != M.end())
    ans.push_back(it1->second);
  else
    ans.push_back(it2->second);
  while (ans.size() < n) {
    int i = ans.size() - 1;
    auto it = M.find(make_pair(ans[i], ans[i - 1]));
    ans.push_back(it->second);
  }
  for (int i = n - 1; i >= 0; i--) cout << ans[i] << " ";
}
