#include <bits/stdc++.h>
using namespace std;
int main() {
  map<int, int> deg, M;
  int n, i, j, k;
  cin >> n;
  for (i = 0; i < n; ++i) {
    cin >> j >> k;
    deg[j]++;
    deg[k]--;
    M[j] = k;
  }
  vector<int> arr(n, 0);
  int f = -1;
  for (auto& [x, y] : deg) {
    if (y == 1) {
      f = x;
      break;
    }
  }
  assert(f != -1);
  arr[0] = f;
  arr[1] = M[0];
  for (int i = 2; i < n; i++) {
    arr[i] = M[arr[i - 2]];
  }
  for (int i = 0; i < n; i++) {
    cout << arr[i] << " ";
  }
}
