#include <bits/stdc++.h>
using namespace std;
int vis[5000000], data1[5000000], data2[5000000];
int ant[5000000];
int main() {
  int i, j;
  int m, n;
  int a, b;
  while (~scanf("%d", &n)) {
    memset(data1, -1, sizeof(data1));
    memset(data2, -1, sizeof(data2));
    memset(vis, 0, sizeof(vis));
    for (i = 1; i <= n; i++) {
      scanf("%d %d", &a, &b);
      data1[a] = b;
      data2[b] = a;
      vis[a] = 1;
      vis[b] = 1;
    }
    int tmp = 0;
    int k = 2;
    while (1) {
      ant[k] = data1[tmp];
      vis[ant[k]] = 0;
      k += 2;
      tmp = data1[tmp];
      if (tmp <= 0) break;
    }
    int mid;
    for (i = 1; i <= 5000000 * 4; i++) {
      if (vis[i]) {
        mid = i;
        break;
      }
    }
    tmp = mid;
    while (1) {
      if (data2[tmp] < 0) break;
      tmp = data2[tmp];
    }
    k = 1;
    while (1) {
      ant[k] = tmp;
      tmp = data1[tmp];
      k += 2;
      if (tmp <= 0) break;
    }
    for (i = 1; i < n; i++) printf("%d ", ant[i]);
    printf("%d\n", ant[i]);
  }
}
