#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000 * 100 + 10;
vector<long long> adj[MAXN];
vector<long long> d;
vector<long long> ans;
long long a[MAXN][2];
int n;
set<long long> s;
bool mark[MAXN];
void dfs(int v) {
  mark[v] = true;
  ans.push_back(v);
  for (int i = 0; i < adj[v].size(); i++)
    if (!mark[adj[v][i]]) dfs(adj[v][i]);
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i][0] >> a[i][1];
    s.insert(a[i][0]);
    s.insert(a[i][1]);
  }
  for (set<long long>::iterator it = s.begin(); it != s.end(); it++)
    d.push_back(*it);
  for (int i = 0; i < n; i++) {
    int u = lower_bound(d.begin(), d.end(), a[i][0]) - d.begin();
    int v = lower_bound(d.begin(), d.end(), a[i][1]) - d.begin();
    adj[v].push_back(u);
    adj[u].push_back(v);
  }
  for (int i = 0; i < d.size(); i++) {
    if (adj[i].size() == 1) {
      dfs(i);
      break;
    }
  }
  for (int i = 0; i < ans.size(); i++) cout << d[ans[i]] << " ";
  return 0;
}
