#include <bits/stdc++.h>
using namespace std;
const int N = 300020;
long long int n;
map<long long int, long long int> mp;
long long int sz = 0;
vector<long long int> g[N];
bool v[N] = {0};
vector<long long int> ans;
map<long long int, long long int> rev;
void dfs(long long int x, long long int pa) {
  v[x] = 1;
  ans.push_back(x);
  for (auto y : g[x]) {
    if (y == pa || v[y]) continue;
    dfs(y, x);
  }
}
long long int deg[N] = {0};
int main() {
  cin >> n;
  for (long long int i = 1; i <= n; i++) {
    long long int x, y;
    cin >> x >> y;
    long long int val1, val2;
    if (mp[x])
      val1 = mp[x];
    else {
      mp[x] = ++sz;
      val1 = mp[x];
      rev[val1] = x;
    }
    if (mp[y])
      val2 = mp[y];
    else {
      mp[y] = ++sz;
      val2 = mp[y];
      rev[val2] = y;
    }
    deg[val1]++;
    deg[val2]++;
    g[val1].push_back(val2);
    g[val2].push_back(val1);
  }
  long long int mmin = 9999999999;
  long long int anss = 1;
  for (long long int i = 1; i <= sz; i++) {
    if (deg[i] < mmin) {
      mmin = deg[i];
      anss = i;
    }
  }
  dfs(anss, 0);
  for (long long int i = 0; i < ans.size(); i++) cout << rev[ans[i]] << " ";
  return 0;
}
