#include <bits/stdc++.h>
using namespace std;
int mod1 = int(1e9) + 7;
unordered_map<int, int> mml, af, bf;
int main() {
  int n, x, y;
  cin >> n;
  vector<int> al;
  for (int i = 0; i < (int)(n); ++i) {
    int a, b;
    cin >> a >> b;
    mml[a] = b;
    af[a] = 1;
    bf[b] = 1;
    al.push_back(a);
    al.push_back(b);
    if (a == 0) y = b;
  }
  for (int i = 0; i < (int)(al.size()); ++i) {
    if (af[al[i]] == 1 && bf[al[i]] == 0) {
      x = al[i];
      break;
    }
  }
  y = mml[0];
  cout << x << " " << y << " ";
  while (mml[x]) {
    int xx = y;
    y = mml[x];
    x = xx;
    cout << y << " ";
  }
  cout << endl;
  return 0;
}
