#include <bits/stdc++.h>
using namespace std;
int LA[1000005], LB[1000005], a[1000005], b[1000005], ans[1000005], X1[1000005],
    X2[1000005];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &a[i], &b[i]);
    LA[a[i]] = i, LB[b[i]] = i;
    X1[a[i]]++, X2[b[i]]++;
  }
  for (int i = 0; i <= 1000000; i++) {
    if (X1[i] == 1 && X2[i] == 0) ans[1] = i;
  }
  ans[2] = b[LA[0]];
  cout << ans[1] << " " << ans[2] << " ";
  for (int i = 3; i <= n; i++) {
    ans[i] = b[LA[ans[i - 2]]];
    cout << ans[i] << " ";
  }
  return 0;
}
