#include <bits/stdc++.h>
using namespace std;
int back[1000001];
int res[1000001];
int cnt[1000001];
int cnt2[1000001];
int main() {
  ios::sync_with_stdio(0);
  int n;
  cin >> n;
  int s = 0;
  for (int i = 0; i < n; ++i) {
    int a, b;
    cin >> a >> b;
    if (a == 0)
      s = b;
    else {
      back[a] = b;
    }
    cnt[a]++;
    cnt2[b]++;
  }
  int f = 0;
  for (int i = 1; i <= 1000000; ++i) {
    if (cnt[i] + cnt2[i] == 1 && cnt[i] == 1) {
      f = i;
      break;
    }
  }
  cout << f << " " << s;
  for (int i = 1; i < (n + 1) / 2; ++i) {
    if (back[f]) {
      cout << " " << back[f];
      f = back[f];
    }
    if (back[s]) {
      cout << " " << back[s];
      s = back[s];
    } else
      break;
  }
  cout << "\n";
  return 0;
}
