#include <bits/stdc++.h>
using namespace std;
int main() {
  int n(0), temp(0), temp1(0);
  ;
  map<int, int> mp1, mp2;
  vector<int> a, b;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> temp >> temp1;
    mp1[temp] = temp1;
    mp2[temp1] = temp;
  }
  temp = 0;
  while (mp1[temp] != 0) {
    a.push_back(mp1[temp]);
    temp = mp1[temp];
  }
  if (n % 2 == 0) {
    temp = 0;
    while (mp2[temp] != 0) {
      b.push_back(mp2[temp]);
      temp = mp2[temp];
    }
    reverse(b.begin(), b.end());
    for (int i = 0; i < a.size(); ++i) cout << b.at(i) << " " << a.at(i) << " ";
    cout << endl;
  } else {
    bool flag = false;
    for (map<int, int>::iterator it = mp2.begin(); it != mp2.end(); ++it) {
      if ((find(a.begin(), a.end(), it->first) == a.end()) &&
          (it->first != 0)) {
        flag = true;
        temp = (*it).first;
        while (mp1[temp] != 0) temp = mp1[temp];
        b.push_back(temp);
        while (mp2[temp] != 0) {
          b.push_back(mp2[temp]);
          temp = mp2[temp];
        }
      }
      if (flag) break;
    }
    reverse(b.begin(), b.end());
    for (int i = 0; i < b.size(); ++i)
      if (i != b.size() - 1)
        cout << b.at(i) << " " << a.at(i) << " ";
      else
        cout << b.at(i) << endl;
  }
  return 0;
}
