#include <bits/stdc++.h>
using namespace std;
vector<vector<long long int>> G(200005);
vector<bool> vis(200005);
vector<long long int> res;
void dfs(long long int u) {
  vis[u] = true;
  res.push_back(u);
  for (auto v : G[u]) {
    if (!vis[v]) {
      dfs(v);
    }
  }
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int n;
  cin >> n;
  vector<long long int> original;
  unordered_map<long long int, long long int> map_original;
  vector<pair<long long int, long long int>> edges;
  for (long long int i = 0; i < n; i++) {
    long long int u, v;
    cin >> u >> v;
    original.push_back(u);
    original.push_back(v);
    edges.push_back(make_pair(u, v));
  }
  sort(original.begin(), original.end());
  auto it = unique(original.begin(), original.end());
  original.resize(distance(original.begin(), it));
  for (long long int i = 0; i < original.size(); i++) {
    map_original[original[i]] = i;
  }
  for (long long int i = 0; i < edges.size(); i++) {
    long long int u = map_original[edges[i].first];
    long long int v = map_original[edges[i].second];
    G[u].push_back(v);
    G[v].push_back(u);
  }
  dfs(0);
  for (long long int i = 0; i < 200005; i++) vis[i] = false;
  long long int last = res.back();
  res.clear();
  dfs(last);
  for (long long int i = 0; i < res.size(); i++)
    cout << original[res[i]] << " ";
  cout << endl;
}
