#include <bits/stdc++.h>
using namespace std;
int a[1000000];
int b[1000000];
vector<int> used;
vector<bool> mark(1000001);
int fin[5 * 100001];
int main() {
  int n;
  cin >> n;
  for (int k = 1; k <= n; k++) {
    int x, y;
    cin >> x >> y;
    used.push_back(x);
    if (x == 0) fin[2] = y;
    mark[y] = true;
    a[x] = y;
  }
  sort(used.begin(), used.end());
  for (int k = 0; k < used.size(); k++) {
    if (!mark[used[k]]) {
      fin[1] = used[k];
      break;
    }
  }
  int x = 2;
  int y = 1;
  int k = 4;
  while (k <= n) {
    fin[k] = a[fin[x]];
    x = k;
    k += 2;
  }
  int i = 3;
  while (i <= n) {
    fin[i] = a[fin[y]];
    y = i;
    i += 2;
  }
  for (int j = 1; j <= n; j++) cout << fin[j] << " ";
  return 0;
}
