#include <bits/stdc++.h>
using namespace std;
map<long long int, vector<long long int>> v;
map<long long int, long long int> vis;
void dfs(long long int n) {
  long long int i;
  cout << n << " ";
  vis[n] = 1;
  for (i = 0; i < v[n].size(); i++) {
    if (!vis[v[n][i]]) {
      vis[v[n][i]] = 1;
      dfs(v[n][i]);
    }
  }
}
int main() {
  long long int n, i, j, k, p, q, ans = 0;
  cin >> n;
  map<long long int, long long int> make_pair;
  for (i = 1; i <= n; i++) {
    cin >> p >> q;
    v[p].push_back(q);
    v[q].push_back(p);
    make_pair[p]++;
    make_pair[q]++;
  }
  for (auto it : make_pair) {
    if (it.second == 1) {
      ans = it.first;
      break;
    }
  }
  dfs(ans);
}
