#include <bits/stdc++.h>
using namespace std;
map<long long int, vector<long long int>> v;
map<long long int, bool> vis;
void dfs(long long int x, map<long long int, vector<long long int>>& v,
         map<long long int, bool>& vis) {
  if (vis[x] == 0) {
    cout << x << " ";
    vis[x] = 1;
  }
  for (long long int i = 0; i < v[x].size(); i++) {
    if (vis[v[x][i]] == 0) {
      vis[v[x][i]] = 0;
      dfs(v[x][i], v, vis);
    }
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n;
  cin >> n;
  long long int val;
  set<long long int> s;
  for (long long int i = 0; i < n; i++) {
    long long int a, b;
    cin >> a >> b;
    v[a].push_back(b);
    v[b].push_back(a);
    s.insert(a);
    s.insert(b);
  }
  set<long long int>::iterator it;
  it = s.begin();
  while (it != s.end()) {
    if (v[*it].size() == 1) {
      val = *it;
      break;
    }
    it++;
  }
  dfs(val, v, vis);
}
