#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
int cnt[1000010], ne[1000010], st;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = (1); i <= (n); i++) {
    int x, y;
    cin >> x >> y;
    cnt[x]++;
    cnt[y]--;
    ne[x] = y;
  }
  while (cnt[st] != 1) st++;
  int a = st, b = ne[0];
  while (a && b) {
    cout << a << " " << b << " ";
    a = ne[a], b = ne[b];
  }
  if (a) cout << a << " ";
  return 0;
}
