#include <bits/stdc++.h>
using namespace std;
map<long long int, vector<long long int>> adj;
set<long long int> s;
void dfs(long long int root, long long int par) {
  cout << root << " ";
  for (auto i : adj[root]) {
    if (i != par) dfs(i, root);
  }
}
int main() {
  long long int n;
  cin >> n;
  for (long long int i = 0; i < n; i++) {
    long long int x, y;
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
    if (s.find(x) == s.end())
      s.insert(x);
    else
      s.erase(x);
    if (s.find(y) == s.end())
      s.insert(y);
    else
      s.erase(y);
  }
  auto it = s.begin();
  dfs(*it, -1);
}
