#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
long long n;
unordered_map<long long, vector<long long>> g;
unordered_map<long long, bool> vis;
void dfs(long long i) {
  vis[i] = 1;
  cout << i << ' ';
  for (auto j : g[i])
    if (!vis[j]) dfs(j);
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  long long i, j, x, y;
  for (i = 1; i <= n; ++i) {
    cin >> x >> y;
    g[x].push_back(y), g[y].push_back(x);
  }
  for (auto it : g)
    if (it.second.size() == 1) {
      dfs(it.first);
      return 0;
    }
  return 0;
}
