#include <bits/stdc++.h>
using namespace std;
const int inf = 1e6 + 3;
struct note {
  int l, r;
};
int n, res[inf * 2], l[inf * 2], r[inf * 2];
int used[inf];
int f_r(int k) {
  if (r[k] == 0)
    return k;
  else
    return (f_r(r[k]));
}
int main() {
  cin >> n;
  int cl, cr;
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", &cl, &cr);
    used[cr] = 1;
    used[cl] = 1;
    r[cl] = cr;
    l[cr] = cl;
  }
  int cur = 0;
  for (int i = 2; i <= n; i += 2) {
    used[r[cur]] = 2;
    res[i] = r[cur];
    cur = r[cur];
  }
  cur = 0;
  int b;
  if (n % 2 == 0) {
    cur = 0;
    b = n - 1;
    for (int i = b; i >= 1; i -= 2) {
      res[i] = l[cur];
      cur = l[cur];
    }
  } else {
    b = n;
    int k = 0;
    for (int i = 1;; i++)
      if (used[i] == 1) {
        k = i;
        break;
      }
    cur = f_r(k);
    for (int i = b; i >= 1; i -= 2) {
      res[i] = cur;
      cur = l[cur];
    }
  }
  for (int i = 1; i <= n; i++) {
    printf("%d ", res[i]);
  }
  return 0;
}
