#include <bits/stdc++.h>
const double PI = acos(-1.0);
const int INF = 0x3f3f3f3f;
using namespace std;
const double eps = 1e-6;
const int MAXN = 2e5 + 10;
const int MOD = 1000007;
struct POINT {
  int pre, next;
  bool operator<(const POINT &a) const { return pre < a.pre; }
} pit[MAXN];
int ans[MAXN], in[MAXN], out[MAXN], n;
map<int, int> inMap, outMap;
int Solve(int val) {
  int l = 0, r = n, mid;
  while (l < r) {
    mid = (l + ((r - l) >> 1));
    if (pit[mid].pre == val) return mid;
    if (pit[mid].pre < val)
      l = mid + 1;
    else
      r = mid;
  }
  return -1;
}
int main() {
  int i, j;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int a, b;
    scanf("%d%d", &pit[i].pre, &pit[i].next);
    inMap[pit[i].pre]++, outMap[pit[i].next]++;
  }
  sort(pit, pit + n);
  int pos = 2;
  int curPeo = pit[0].next, lstPeo = curPeo;
  while (curPeo != 0) {
    ans[pos] = curPeo;
    lstPeo = curPeo;
    pos += 2;
    int tmpPos = Solve(curPeo);
    if (tmpPos == -1) break;
    curPeo = pit[tmpPos].next;
  }
  pos = 1;
  int bakPeo;
  for (i = 1; i <= n; i++) {
    if (inMap[pit[i].pre] == 1 && outMap[pit[i].pre] == 0) {
      curPeo = pit[i].pre;
      break;
    }
  }
  ans[pos] = curPeo;
  curPeo = pit[i].next;
  pos += 2;
  while (curPeo != 0) {
    ans[pos] = curPeo;
    pos += 2;
    int tmpPos = Solve(curPeo);
    if (tmpPos == -1) break;
    curPeo = pit[tmpPos].next;
  }
  for (i = 1; i <= n; i++) printf("%d ", ans[i]);
  return 0;
}
