#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a, b;
  scanf("%d", &n);
  map<int, int> child, parent, seenm;
  vector<int> list;
  for (int i = 1; i < n + 1; i++) {
    scanf("%d", &a);
    scanf("%d", &b);
    child[a] = b;
    parent[b] = a;
    if (a > 0 && !seenm[a]) list.push_back(a);
    if (b > 0 && !seenm[b]) list.push_back(b);
    seenm[a] = 1;
    seenm[b] = 1;
  }
  vector<int> id(n + 1, 0);
  map<int, int> seen;
  int seen_count = 0;
  int x = 0, pos = 2;
  while (child[x]) {
    id[pos] = child[x];
    x = child[x];
    seen[x] = 1;
    seen_count++;
    pos += 2;
  }
  if (n % 2 == 0) {
    x = 0;
    pos = n - 1;
    while (parent[x]) {
      id[pos] = parent[x];
      x = parent[x];
      pos -= 2;
    }
  } else {
    x = 0;
    for (int i = 1; i < n + 1; i++)
      if (!seen[list[i - 1]]) {
        x = list[i - 1];
        break;
      }
    while (parent[x]) x = parent[x];
    pos = 1;
    while (x) {
      id[pos] = x;
      x = child[x];
      pos += 2;
    }
  }
  for (int i = 1; i < n + 1; i++) printf("%d%c", id[i], i < n ? ' ' : '\n');
  return 0;
}
