#include <bits/stdc++.h>
using namespace std;
int same[1000010];
int a[1000010];
int b[1000010];
int ans[1000010];
int coun[1000010];
int main() {
  int n, p, q;
  cin >> n;
  for (int i = 0; i < 1000010; i++) same[i] = -1;
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
    coun[a[i]]++;
    coun[b[i]]++;
    same[a[i]] = b[i];
    if (a[i] == 0) p = b[i];
    if (b[i] == 0) q = a[i];
  }
  int xx, yy;
  for (int i = 0; i < n; i++) {
    if (coun[a[i]] == 1) xx = a[i];
    if (coun[b[i]] == 1) yy = b[i];
  }
  if (same[xx] != -1) {
    ans[0] = xx;
    for (int i = 0; i < n; i += 2) ans[i + 2] = same[ans[i]];
  } else {
    ans[0] = yy;
    for (int i = 0; i < n; i += 2) ans[i + 2] = same[ans[i]];
  }
  ans[1] = p;
  for (int i = 1; i < n; i++) ans[i + 2] = same[ans[i]];
  for (int i = 0; i < n; i++) cout << ans[i] << " ";
  cout << endl;
}
