#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  map<int, int> m;
  map<int, int> ed;
  for (int i = 0; i < n; ++i) {
    int x, y;
    cin >> x >> y;
    if (y) ed[x] = y;
    if (y) m[y] += 1;
    if (m.count(x) == 0) {
      m[x] = 0;
    }
  }
  int ans[n];
  int ini = 1;
  int po = 0;
  while (ed.count(po)) {
    ans[ini] = ed[po];
    ini += 2;
    po = ed[po];
  }
  ini = 0;
  for (auto it = m.begin(); it != m.end(); ++it) {
    if (it->second == 0 && it->first != 0) {
      po = it->first;
      break;
    }
  }
  while (1) {
    ans[ini] = po;
    ini += 2;
    if (ed.count(po))
      po = ed[po];
    else
      break;
  }
  for (int i = 0; i < n; ++i) {
    printf("%d ", ans[i]);
  }
  return 0;
}
