#include <bits/stdc++.h>
using namespace std;
int n;
map<int, int> mp;
set<int> starts;
const int MAX = 10e5 + 3;
vector<int> adj[MAX];
int values[MAX];
void DFS(int index, int p = -1) {
  cout << values[index] << " ";
  for (int ch : adj[index]) {
    if (ch != p) {
      DFS(ch, index);
    }
  }
}
int main(int argc, char const *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  int index = 0;
  for (int i = 0; i < n; ++i) {
    int src, des;
    cin >> src >> des;
    if (mp.find(src) == mp.end()) {
      mp[src] = index;
      starts.insert(src);
      values[index] = src;
      ++index;
    } else {
      starts.erase(src);
    }
    if (mp.find(des) == mp.end()) {
      mp[des] = index;
      starts.insert(des);
      values[index] = des;
      ++index;
    } else {
      starts.erase(des);
    }
    adj[mp[src]].push_back(mp[des]);
    adj[mp[des]].push_back(mp[src]);
  }
  int start = *(starts.begin());
  DFS(mp[start]);
  return 0;
}
