#include <bits/stdc++.h>
using namespace std;
const int size = 5555;
vector<int> V[4];
int a, n, b[1111111], c[1111111], x;
int res[1111111];
int main() {
  cin >> n;
  int pre = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a >> x;
    c[x] = a;
    b[a] = x;
  }
  for (int i = 2; b[pre]; i += 2, pre = b[pre]) res[i] = b[pre], c[b[pre]] = 0;
  for (int i = 0; i <= 1000000; i++)
    if (c[i] && c[c[i]] == 0) pre = c[i];
  for (int i = 1; pre; i += 2, pre = b[pre]) res[i] = pre;
  for (int i = 1; i <= n; i++) {
    if (i > 1) printf(" ");
    printf("%d", res[i]);
  }
  printf("\n");
}
