#include <bits/stdc++.h>
const int MAX = 1e6 + 11;
using namespace std;
int N, A[MAX], B[MAX], R1[MAX], R2[MAX], R[MAX];
int main() {
  memset((R1), 0xFF, sizeof(R1));
  memset((R2), 0xFF, sizeof(R2));
  scanf("%d", &(N));
  for (int i = 0; i < (N); ++i) scanf("%d%d", &(A[i]), &(B[i]));
  for (int i = 0; i < (N); ++i) {
    R1[A[i]] = i;
    R2[B[i]] = i;
  }
  vector<int> beg, end;
  if (N % 2 == 0) {
    int pos = 0;
    while (R1[pos] != -1) {
      int x = R1[pos];
      beg.push_back(B[x]);
      pos = B[x];
    }
    pos = 0;
    while (R2[pos] != -1) {
      int x = R2[pos];
      end.push_back(A[x]);
      pos = A[x];
    }
    reverse(end.begin(), end.end());
  } else {
    int pos = 0;
    while (R1[pos] != -1) {
      int x = R1[pos];
      if (B[x] == 0) break;
      beg.push_back(B[x]);
      pos = B[x];
    }
    for (int i = 0; i < (N); ++i) {
      if (R1[B[i]] == -1) {
        pos = B[i];
        break;
      }
    }
    end.push_back(pos);
    while (R2[pos] != -1) {
      int x = R2[pos];
      end.push_back(A[x]);
      pos = A[x];
    }
    reverse(end.begin(), end.end());
  }
  for (int i = 0; i < (int((end).size())); ++i) {
    R[2 * i] = end[i];
  }
  for (int i = 0; i < (int((beg).size())); ++i) {
    R[2 * i + 1] = beg[i];
  }
  for (int i = 0; i < (N); ++i) {
    printf("%d ", R[i]);
  }
  return 0;
}
