#include <bits/stdc++.h>
const long long int M = 1e9 + 7;
using namespace std;
int main() {
  long long int n, k, i;
  while (cin >> n) {
    map<long long int, long long int> mpa, mpb;
    long long int a, b, ar[n + 5];
    set<long long int> st;
    for (i = 0; i < n; i++) {
      cin >> a >> b, a++, b++;
      mpa[a] = b, mpb[b] = a;
      if (a == 1) ar[1] = b;
      st.insert(a), st.insert(b);
    }
    for (auto it : st)
      if (mpa[it] && !mpb[it]) ar[0] = it;
    for (i = 0; i < n; i++) ar[i + 2] = mpa[ar[i]];
    for (i = 0; i < n; i++) cout << ar[i] - 1 << " ";
    puts("");
  }
  return 0;
}
