#include <bits/stdc++.h>
using namespace std;
int n;
map<int, int> m;
int input[200000][2];
set<int> front, back;
vector<int> seq1, seq2;
int main() {
  cin >> n;
  int num1, num2;
  for (int i = 0; i < n; i++) {
    cin >> input[i][0] >> input[i][1];
    front.insert(input[i][0]);
    back.insert(input[i][1]);
    if (input[i][0] == 0) num2 = input[i][1];
    m[input[i][0]] = input[i][1];
  }
  for (set<int>::iterator sit = front.begin(); sit != front.end(); sit++)
    if (back.find(*sit) == back.end()) {
      num1 = *sit;
      break;
    }
  while (true) {
    seq1.push_back(num1);
    if (m.find(num1) == m.end()) break;
    num1 = m[num1];
    if (num1 == 0) break;
  }
  while (true) {
    seq2.push_back(num2);
    if (m.find(num2) == m.end()) break;
    num2 = m[num2];
    if (num2 == 0) break;
  }
  bool flag = true;
  for (int i = 0; i < seq2.size(); i++) {
    if (!flag) cout << " ";
    flag = false;
    cout << seq1[i] << " " << seq2[i];
  }
  if (seq1.size() != seq2.size()) cout << " " << *seq1.rbegin();
  cout << endl;
  return 0;
}
