#include <bits/stdc++.h>
using namespace std;
vector<int> v[100002], v1;
map<int, int> m, m1, n;
void dfs(int x) {
  printf("%d ", m1[x]);
  n[x]++;
  for (int i = 0; i < v[x].size(); i++) {
    if (!n[v[x][i]]) {
      dfs(v[x][i]);
    }
  }
}
int main() {
  int a, b, c, d, e, i, j, p;
  int x[100002], y[100002];
  cin >> a;
  for (i = 1; i <= a; i++) {
    scanf("%d %d", &b, &c);
    x[i] = b;
    y[i] = c;
    if (!m[b]) {
      v1.push_back(b);
      m[b]++;
    }
    if (!m[c]) {
      v1.push_back(c);
      m[c]++;
    }
  }
  m.clear();
  sort(v1.begin(), v1.end());
  p = 1;
  for (i = 0; i < v1.size(); i++) {
    m[v1[i]] = p;
    m1[p] = v1[i];
    p++;
  }
  for (i = 1; i <= a; i++) {
    x[i] = m[x[i]];
    y[i] = m[y[i]];
  }
  for (i = 1; i <= a; i++) {
    v[x[i]].push_back(y[i]);
    v[y[i]].push_back(x[i]);
  }
  m.clear();
  for (i = 1; i <= a; i++) {
    if (v[i].size() == 1) {
      dfs(i);
      break;
    }
  }
  return 0;
}
