#include <bits/stdc++.h>
using namespace std;
map<long long, vector<long long>> v;
map<long long, long long> visited, dist, pt;
long long mx = 0, nd = 0, mxd = 0, mxn = 0;
void bfs(long long u) {
  visited[u] = 1;
  queue<long long> q;
  q.push(u);
  dist[u] = 0;
  while (!q.empty()) {
    u = q.front();
    visited[u] = 1;
    q.pop();
    visited[u] = 1;
    for (long long i = 0; i < (long long)v[u].size(); i++) {
      long long p = v[u][i];
      if (!visited[p]) {
        visited[p] = 1;
        dist[p] = dist[u] + 1;
        if (dist[p] > mxd) {
          mxd = dist[p];
          mxn = p;
        }
        pt[p] = u;
        q.push(p);
      }
    }
  }
}
int main() {
  long long a, b, x, c, i, j, n, t, k, z = 0, node, edge;
  scanf("%lld", &n);
  for (i = 1; i <= n; i++) {
    scanf("%lld %lld", &a, &b);
    v[a].push_back(b);
    v[b].push_back(a);
    c = a;
  }
  bfs(c);
  x = mxn;
  visited.clear();
  dist.clear();
  pt.clear();
  mxd = 0;
  bfs(mxn);
  vector<long long> path;
  path.push_back(mxn);
  long long now = mxn;
  while (now != x) {
    now = pt[now];
    path.push_back(now);
  }
  for (i = 0; i < (long long)path.size(); i++) cout << path[i] << ' ';
  return 0;
}
