#include <bits/stdc++.h>
using namespace std;
long long x[2000005], y[2000005];
long long id[2000005], nextid[2000005];
bool v[2000005];
long long first = 0, second = 0;
int main() {
  long long n;
  long long i, j;
  memset(v, false, sizeof(v));
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> x[i] >> y[i];
    nextid[x[i]] = y[i];
  }
  for (i = 1; i <= n; i++) {
    v[y[i]] = true;
    if (x[i] == 0) second = y[i];
  }
  for (i = 1; i <= n; i++)
    if (!v[x[i]]) {
      first = x[i];
      break;
    }
  for (i = 1; i <= n; i = i + 2) {
    id[i] = first;
    first = nextid[first];
  }
  for (i = 2; i <= n; i = i + 2) {
    id[i] = second;
    second = nextid[second];
  }
  for (i = 1; i <= n; i++)
    if (i != n)
      cout << id[i] << " ";
    else
      cout << id[i];
  return 0;
}
