#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 5;
int n, a, b, num = 0;
map<int, int> M, O;
map<int, int>::iterator it;
struct graf {
  vector<int> sasiedzi;
  bool visited;
  graf() { visited = false; }
};
graf G[MAXN];
int skaluj(int x) {
  it = M.find(x);
  if (it != M.end()) return it->second;
  num++;
  M.insert(make_pair(x, num));
  O.insert(make_pair(num, x));
  return num;
}
int odskaluj(int x) {
  it = O.find(x);
  return it->second;
}
void BFS(int x) {
  cout << odskaluj(x) << " ";
  G[x].visited = true;
  queue<int> Q;
  Q.push(x);
  while (!Q.empty()) {
    int k = Q.front();
    Q.pop();
    for (int i = 0; i < (int)G[k].sasiedzi.size(); i++) {
      int u = G[k].sasiedzi[i];
      if (G[u].visited) continue;
      G[u].visited = true;
      cout << odskaluj(u) << " ";
      Q.push(u);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a >> b;
    a = skaluj(a);
    b = skaluj(b);
    G[a].sasiedzi.push_back(b);
    G[b].sasiedzi.push_back(a);
  }
  int v;
  for (int i = 1; i <= n; i++)
    if (G[i].sasiedzi.size() == 1) {
      v = i;
      break;
    }
  BFS(v);
  return 0;
}
