#include <bits/stdc++.h>
using namespace std;
map<int, vector<int>> adj;
int k;
void bfs1(int s) {
  map<int, bool> vis;
  queue<int> q;
  int u, v;
  vis[s] = 1;
  q.push(s);
  while (!q.empty()) {
    u = q.front();
    q.pop();
    for (int i = 0; i < adj[u].size(); i++) {
      v = adj[u][i];
      if (!vis[v]) {
        vis[v] = 1;
        q.push(v);
        k = v;
      }
    }
  }
}
void bfs2(int s) {
  map<int, bool> vis;
  cout << s << " ";
  queue<int> q;
  int u, v;
  vis[s] = 1;
  q.push(s);
  while (!q.empty()) {
    u = q.front();
    q.pop();
    for (int i = 0; i < adj[u].size(); i++) {
      v = adj[u][i];
      if (!vis[v]) {
        vis[v] = 1;
        q.push(v);
        cout << v << " ";
      }
    }
  }
}
int main() {
  int n, u, v;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  bfs1(u);
  bfs2(k);
  return 0;
}
