#include <bits/stdc++.h>
using namespace std;
const int maxn = 2 * 100000 + 5;
const int maxd = 1000000 + 5;
int n, i, j, k;
int a[maxd];
int b[maxd];
int vis[maxd];
int x[maxn];
int y[2 * maxn];
int main() {
  cin >> n;
  memset(a, -1, sizeof(a));
  memset(b, -1, sizeof(b));
  for (i = 0; i < 2 * n; i += 2) {
    cin >> y[i] >> y[i + 1];
    a[y[i]] = y[i + 1];
    b[y[i + 1]] = y[i];
  }
  i = 0;
  j = 1;
  vis[0] = 1;
  while (a[i] != 0 && a[i] != -1) {
    vis[a[i]] = 1;
    x[j] = a[i];
    i = a[i];
    j += 2;
  }
  for (k = 0; k < 2 * n; k++)
    if (!vis[y[k]]) {
      i = y[k];
      break;
    }
  while (b[i] != -1) i = b[i];
  x[0] = i;
  j = 2;
  while (a[i] != 0 && a[i] != -1) {
    x[j] = a[i];
    i = a[i];
    j += 2;
  }
  if (n % 2) j--;
  for (i = 0; i < j; i++) {
    if (i == j - 1)
      cout << x[i] << endl;
    else
      cout << x[i] << " ";
  }
  return 0;
}
