#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  int adj[1000005];
  int as[200005];
  bool inb[1000005];
  int q[200005];
  cin >> n;
  for (int i = 1; i <= n; i++) inb[i] = false;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    adj[a] = b;
    as[i] = a;
    inb[b] = true;
  }
  for (int i = 0; i < n; i++) {
    if (not inb[as[i]]) {
      q[0] = as[i];
      break;
    }
  }
  q[1] = adj[0];
  for (int i = 2; i <= n; i++) q[i] = adj[q[i - 2]];
  for (int i = 0; i < n; i++) cout << q[i] << " ";
  cout << endl;
  return 0;
}
