#include <bits/stdc++.h>
using namespace std;
int n, k, x, y;
map<int, int> m, M;
vector<int> v[200001];
bool us[200001];
void dfs(int x) {
  us[x] = 1;
  cout << M[x] << " ";
  for (int i = 0; i < v[x].size(); i++) {
    int V = v[x][i];
    if (!us[V]) dfs(V);
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin >> n;
  while (n--) {
    cin >> x >> y;
    if (!m[x]) m[x] = ++k, M[k] = x;
    if (!m[y]) m[y] = ++k, M[k] = y;
    v[m[x]].push_back(m[y]);
    v[m[y]].push_back(m[x]);
  }
  for (int i = 1; i <= k; i++)
    if (v[i].size() == 1) {
      dfs(i);
      cout << endl;
      return 0;
    }
  return 0;
}
