#include <bits/stdc++.h>
using namespace std;
int n, a, b, root;
const int N = 100005;
map<int, vector<int>> v;
vector<int> ord;
map<int, int> V, m;
set<int> s;
void dfs(int u) {
  V[u] = 1;
  for (int i = 0; i < v[u].size(); ++i)
    if (!V[v[u][i]]) dfs(v[u][i]);
  ord.push_back(u);
}
int main() {
  cin >> n;
  for (int i = 0; i < n; ++i)
    cin >> a >> b, v[a].push_back(b), v[b].push_back(a), ++m[a], ++m[b],
        s.insert(a), s.insert(b);
  for (auto x : s)
    if (m[x] == 1) {
      root = x;
      break;
    }
  dfs(root);
  for (auto x : ord) cout << x << " ";
}
