#include <bits/stdc++.h>
using namespace std;
const int inf = 1e6 + 10;
map<int, int> mas;
unordered_set<int> u;
bool used[inf];
int main() {
  int n;
  int a, b;
  int x, y;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a >> b;
    used[b] = true;
    u.insert(a);
    mas[a] = b;
    if (a == 0) y = b;
  }
  for (int i : u) {
    if (!used[i]) x = i;
  }
  cout << x << ' ' << y << ' ';
  int res[inf];
  res[1] = x;
  res[2] = y;
  for (int i = 3; i <= n; i++) {
    res[i] = mas[res[i - 2]];
    cout << res[i] << ' ';
  }
  return 0;
}
