#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> v;
map<int, int> a, b;
int main() {
  cin >> n;
  for (int i = (0); i < (n); i++) {
    int x, y;
    cin >> x >> y;
    v.push_back(x);
    v.push_back(y);
    if (a[x])
      b[x] = y;
    else
      a[x] = y;
    if (a[y])
      b[y] = x;
    else
      a[y] = x;
  }
  int p = 0;
  for (int i = (0); i < (v.size()); i++) {
    if (!b[v[i]]) {
      p = v[i];
      break;
    }
  }
  int now = p, prv = -1;
  for (int i = (0); i < (n + 1); i++) {
    cout << p << ' ';
    if (a[p] != prv)
      p = a[p];
    else
      p = b[p];
    prv = now, now = p;
  }
}
