#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 12, big = 1e18, mod = 1e9 + 7;
const double pi = acos(-1);
map<long long, long long> m;
long long n, x, y;
map<long long, vector<long long> > a;
void dfs(long long i, long long pa) {
  cout << i << " ";
  for (int j : a[i])
    if (j != pa) dfs(j, i);
}
int main() {
  cin >> n;
  while (n--)
    cin >> x >> y, a[x].push_back(y), a[y].push_back(x), m[x]++, m[y]++;
  for (auto i : m)
    if (i.second == 1) {
      dfs(i.first, 0);
      return 0;
    }
}
