#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  set<int> ss;
  map<int, int> m;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int f, s;
    cin >> f >> s;
    m[f] = s;
    ss.insert(f);
    ss.insert(s);
  }
  for (auto i : m) {
    int val = i.second;
    ss.erase(val);
  }
  vector<int> ans;
  cout << *(ss.begin()) << " ";
  cout << m[0] << " ";
  int fi = *(ss.begin());
  int se = m[0];
  for (int i = 0; i < n - 2; i++) {
    int val = m[fi];
    cout << val << " ";
    fi = se;
    se = val;
  }
  cout << endl;
  return 0;
}
