#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, i, tmp_ara1, tmp_ara2;
  vector<long long> ara1(2000007, -1), ara2(2000007, -1), ans(200007, -1),
      in_front;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> tmp_ara1 >> tmp_ara2;
    ara1[tmp_ara1] = tmp_ara2;
    ara2[tmp_ara2] = tmp_ara1;
    in_front.push_back(tmp_ara1);
  }
  long long key = 0;
  for (i = 2; i <= n; i += 2) {
    ans[i] = ara1[key];
    key = ara1[key];
  }
  long long first;
  for (i = 0; i < n; i++) {
    if (ara2[in_front[i]] == -1) {
      first = in_front[i];
      break;
    }
  }
  key = first;
  ans[1] = first;
  for (i = 3; i <= n; i += 2) {
    ans[i] = ara1[key];
    key = ara1[key];
  }
  for (i = 1; i <= n; i++) {
    cout << ans[i] << " ";
  }
  return 0;
}
