#include <bits/stdc++.h>
using namespace std;
int res[2 * 100002];
vector<int> v[1000020], vv;
int main() {
  int n, a, b;
  cin >> n;
  map<int, int> mp;
  for (int i = 1; i <= n; i++) {
    cin >> a >> b;
    v[a].push_back(b);
    if (a != 0) vv.push_back(a);
    if (a == 0) res[2] = b;
    if (b == 0) res[n - 1] = a;
    mp[a]++;
    mp[b]++;
  }
  for (int i = 0; i < n; i++)
    if (mp[vv[i]] == 1) {
      res[1] = vv[i];
      break;
    }
  int x = res[1];
  int i = 1;
  while (v[x].size() > 0) {
    if (v[x][0] == 0) break;
    i += 2;
    res[i] = v[x][0];
    x = v[x][0];
  }
  i = 2;
  x = res[2];
  while (v[x].size() != 0) {
    if (v[x][0] == 0) break;
    i += 2;
    x = v[x][0];
    res[i] = x;
  }
  for (int i = 1; i <= n; i++) cout << res[i] << " ";
}
