#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int n, arr[N][3], vis[N];
vector<int> ans;
void solve(int idx, int nxt) {
  ans.push_back(idx);
  if (ans.size() == n) {
    if (arr[idx][1] == nxt || arr[idx][2] == nxt) {
      for (auto p : ans) cout << p << " ";
      exit(0);
    }
    return;
  }
  vis[idx] = 1;
  if (arr[idx][1] == nxt && !vis[nxt]) solve(arr[idx][1], arr[idx][2]);
  if (arr[idx][2] == nxt && !vis[nxt]) solve(arr[idx][2], arr[idx][1]);
  vis[idx] = 0;
  ans.pop_back();
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> arr[i][1] >> arr[i][2];
  }
  solve(1, arr[1][1]);
  solve(1, arr[1][2]);
}
