#include <bits/stdc++.h>
using namespace std;
int a[1000005], b[1000005], sol[2 * 100005], n, i, j, k, x, y, z, f;
bool c[1000005];
int main() {
  cin >> n;
  for (i = 1; i <= n; ++i) {
    cin >> x >> y;
    a[x] = y;
    b[y] = x;
    if (c[x])
      c[x] = 0;
    else
      c[x] = 1;
    if (c[y])
      c[y] = 0;
    else
      c[y] = 1;
  }
  i = 0;
  k = 0;
  do {
    k += 2;
    sol[k] = a[i];
    i = a[i];
  } while (a[i]);
  if (n % 2 == 0) {
    i = 0;
    k = n + 1;
    do {
      k -= 2;
      sol[k] = b[i];
      i = b[i];
    } while (b[i]);
  } else {
    for (i = 1; i <= 1000005; ++i)
      if (c[i]) {
        k = i;
        i = 1000006;
      }
    sol[1] = k;
    z = k;
    i = k;
    k = 1;
    if (a[i]) do {
        k += 2;
        sol[k] = a[i];
        i = a[i];
      } while (a[i]);
  }
  if (sol[n] == 0) {
    k = z;
    sol[n] = k;
    i = k;
    k = n;
    do {
      k -= 2;
      sol[k] = b[i];
      i = b[i];
    } while (b[i]);
  }
  for (i = 1; i <= n; ++i) cout << sol[i] << ' ';
  return 0;
}
