#include <bits/stdc++.h>
using namespace std;
pair<vector<int>, vector<int>> b[1000001];
int main() {
  int n;
  cin >> n;
  pair<int, int> a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i].first >> a[i].second;
    b[a[i].second].first.push_back(a[i].first);
    b[a[i].first].second.push_back(a[i].second);
  }
  int d[n], s1 = 0, s2, x = 0, s3;
  for (int i = 0; i < n; i++) {
    if (b[a[i].first].first.empty()) {
      s2 = a[i].first;
      break;
    }
  }
  while (s2 != 0) {
    d[x] = s2;
    s3 = s2;
    s2 = b[s1].second.front();
    s1 = s3;
    x++;
  }
  for (int i = 0; i < n; i++) cout << d[i] << " ";
  cout << endl;
  return 0;
}
