#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5;
int pset[MAXN], rk[MAXN], numS;
void init(int N) {
  for (int i = (1); i <= (N); ++i) {
    pset[i] = i;
    rk[i] = 1;
  }
  numS = N;
}
int findSet(int i) { return (pset[i] == i) ? i : (pset[i] = findSet(pset[i])); }
bool isSameSet(int i, int j) { return findSet(i) == findSet(j); }
void unionSet(int i, int j) {
  if (!isSameSet(i, j)) {
    if (rk[findSet(i)] >= rk[findSet(j)]) {
      rk[findSet(i)] += rk[findSet(j)];
      rk[findSet(j)] = 0;
      pset[findSet(j)] = findSet(i);
    } else {
      rk[findSet(j)] += rk[findSet(i)];
      rk[findSet(i)] = 0;
      pset[findSet(i)] = findSet(j);
    }
    --numS;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  map<int, int> s, occ;
  int ans[n];
  for (int i = (1); i <= (n); ++i) {
    int x, y;
    cin >> x >> y;
    if (x == 0) ans[1] = y;
    s[x] = y;
    ++occ[x];
    ++occ[y];
  }
  int ft = 0;
  for (auto it : s) {
    if (occ[it.first] == 1) {
      ft = it.first;
      break;
    }
  }
  ans[0] = ft;
  for (int i = (2); i <= (n - 1); ++i) ans[i] = s[ans[i - 2]];
  for (int i = (0); i <= (n - 1); ++i) cout << ans[i] << " \n"[i == n - 1];
  return 0;
}
