#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100010;
int v[2 * MAXN];
pair<int, int> edges[MAXN];
vector<int> adj[2 * MAXN];
int par[2 * MAXN];
int ori[2 * MAXN];
int id[2 * MAXN];
int bfs(int src) {
  par[src] = src;
  queue<int> q;
  q.push(src);
  int ans = src;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    if (src == 0)
      if (0)
        cout << "u"
             << " == " << u << endl;
    ans = u;
    for (__typeof((adj[u]).begin()) it = (adj[u]).begin(); it != (adj[u]).end();
         ++it) {
      if (0)
        cout << "*it"
             << " == " << *it << endl;
      if (par[*it] == -1) {
        par[*it] = u;
        q.push(*it);
      }
    }
  }
  return ans;
}
int main() {
  int m;
  scanf(" %d", &(m));
  int n = 0;
  for (int i = 0; i < (m); ++i) {
    int x, y;
    scanf(" %d %d", &(x), &(y));
    edges[i] = {x, y};
    v[n++] = x;
    v[n++] = y;
  }
  sort(v, v + n);
  n = unique(v, v + n) - v;
  for (int i = 0; i < (m); ++i) {
    int x = lower_bound(v, v + n, edges[i].first) - v;
    int y = lower_bound(v, v + n, edges[i].second) - v;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  memset(par, -1, sizeof(par));
  int x = bfs(0);
  memset(par, -1, sizeof(par));
  int y = bfs(x);
  for (int i = 0; i < (n); ++i) id[i] = v[i];
  int vtx = y;
  if (0)
    cout << "x"
         << " == " << x << endl;
  if (0)
    cout << "y"
         << " == " << y << endl;
  while (true) {
    printf("%d ", id[vtx]);
    if (vtx == x) break;
    vtx = par[vtx];
  }
  printf("\n");
  return 0;
}
