#include <bits/stdc++.h>
using namespace std;
set<pair<signed long long int, signed long long int> >::iterator it;
set<pair<signed long long int, signed long long int> > v;
vector<signed long long int> adj[2000001];
vector<signed long long int> adj1[2000001];
signed long long int ans[2000001];
signed long long int valid[2000001];
signed long long int id;
signed long long int flag;
void dfs(signed long long int src) {
  ans[id] = src;
  id += 2;
  for (signed long long int i = 0; i < (signed long long int)adj[src].size();
       i++) {
    v.erase(make_pair(src, adj[src][i]));
    if (adj[src][i] != 0) dfs(adj[src][i]);
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  signed long long int n;
  cin >> n;
  memset(valid, 0, sizeof(valid));
  for (signed long long int i = 1; i <= n; i++) {
    signed long long int a, b;
    cin >> a >> b;
    v.insert(make_pair(a, b));
    adj[a].push_back(b);
  }
  id = 0;
  dfs(0);
  for (it = v.begin(); it != v.end(); it++) {
    signed long long int x = it->first;
    signed long long int y = it->second;
    valid[x] = 1;
    valid[y] = 1;
    adj1[y].push_back(x);
  }
  signed long long int src = 0;
  for (signed long long int i = 0; i <= 2000000; i++) {
    if (valid[i]) {
      if (adj1[i].size() == 0) src = i;
    }
  }
  id = 1;
  dfs(src);
  for (signed long long int i = 1; i <= n; i++) cout << ans[i] << " ";
  cout << "\n";
  return 0;
}
