#include <bits/stdc++.h>
using namespace std;
map<int, bool> visited;
map<int, pair<int, int>> graph;
void dfs(int v) {
  visited[v] = true;
  cout << v << ' ';
  if (!visited[graph[v].first]) dfs(graph[v].first);
  if (graph[v].second != 0 && !visited[graph[v].second]) dfs(graph[v].second);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int A, B;
    cin >> A >> B;
    if (graph[A].first == 0)
      graph[A].first = B;
    else
      graph[A].second = B;
    if (graph[B].first == 0)
      graph[B].first = A;
    else
      graph[B].second = A;
  }
  int magic = 0;
  for (auto P : graph)
    if (P.second.second == 0) {
      magic = P.first;
      break;
    }
  dfs(magic);
  return 0;
}
