#include <bits/stdc++.h>
using namespace std;
const int N = int(2e5);
int n;
vector<int> g[N + 1];
bool vis[N + 1];
map<int, int> mp, pm;
int cur = 1;
void dfs(int num) {
  vis[mp[num]] = true;
  printf("%d ", num);
  for (int i = 0; i < g[mp[num]].size(); ++i) {
    int to = g[mp[num]][i];
    if (!vis[to]) {
      dfs(pm[to]);
    }
  }
}
int main(int argc, char *argv[]) {
  memset(vis, false, sizeof(vis));
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    int from, to;
    scanf("%d%d", &from, &to);
    if (!mp[from]) {
      mp[from] = cur;
      pm[cur] = from;
      cur++;
    }
    if (!mp[to]) {
      mp[to] = cur;
      pm[cur] = to;
      cur++;
    }
    g[mp[from]].push_back(mp[to]);
    g[mp[to]].push_back(mp[from]);
  }
  for (int i = 0;; ++i) {
    if (g[i].size() == 1) {
      dfs(pm[i]);
      return 0;
    }
  }
  return 0;
}
