#include <bits/stdc++.h>
using namespace std;
const int dr[]{-1, -1, 0, 1, 1, 1, 0, -1};
const int dc[]{0, 1, 1, 1, 0, -1, -1, -1};
void run() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
int main() {
  run();
  int n;
  cin >> n;
  set<int> f;
  map<int, int> nxt;
  vector<pair<int, int>> v(n);
  for (auto& [a, b] : v) {
    cin >> a >> b;
    nxt[a] = b;
    f.insert(a);
  }
  for (auto& [a, b] : v) f.erase(b);
  int idx = 0, cur1 = *f.begin(), cur2 = nxt[0];
  vector<int> rt(n + 1);
  while (cur1 != 0) {
    rt[idx++] = cur1;
    rt[idx++] = cur2;
    cur1 = nxt[cur1];
    cur2 = nxt[cur2];
  }
  for (int i = 0; i < n; i++) cout << rt[i] << ' ';
}
