#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int n;
int a[N], b[N];
vector<int> id;
unordered_map<int, int> check;
int ans[N], num[N];
vector<int> border;
int son[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i] >> b[i];
    if (a[i] != 0) {
      if (!check.count(a[i])) {
        check[a[i]] = 1;
        id.push_back(a[i]);
      }
    }
    if (b[i] != 0) {
      if (!check.count(b[i])) {
        check[b[i]] = 1;
        id.push_back(b[i]);
      }
    }
  }
  sort(id.begin(), id.end());
  for (int i = 1; i <= n; i++) {
    if (a[i] != 0) {
      a[i] = lower_bound(id.begin(), id.end(), a[i]) - id.begin() + 1;
    }
    if (b[i] != 0) {
      b[i] = lower_bound(id.begin(), id.end(), b[i]) - id.begin() + 1;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (a[i] == 0) {
      ans[2] = b[i];
    }
    if (a[i] != 0) num[a[i]]++;
    if (b[i] != 0) num[b[i]]++;
  }
  for (int i = 1; i <= n; i++)
    if (num[i] == 1) border.push_back(i);
  for (int i = 1; i <= n; i++) {
    if (a[i] == border[0]) {
      ans[1] = a[i];
      break;
    } else if (a[i] == border[1]) {
      ans[1] = border[1];
      break;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (a[i] != 0 && b[i] != 0) son[a[i]] = b[i];
  }
  for (int i = 3; i <= n; i++) {
    ans[i] = son[ans[i - 2]];
  }
  for (int i = 1; i <= n; i++) cout << id[ans[i] - 1] << " ";
}
