#include <bits/stdc++.h>
using namespace std;
int n, i, j, H[100100], k, C[100100], ss;
map<int, int> mp;
vector<int> E[201000];
void dfs(int v, int par) {
  if (v != ss) printf(" ");
  printf("%d", H[v]);
  for (int i = 0; i < E[v].size(); i++) {
    int w = E[v][i];
    if (w != par) dfs(w, v);
  }
}
int main() {
  scanf("%d", &n);
  k = 0;
  memset(C, 0, sizeof(C));
  for (i = 0; i < n; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    if (mp.count(a) == 0) {
      mp[a] = k;
      H[k] = a;
      k++;
    }
    if (mp.count(b) == 0) {
      mp[b] = k;
      H[k] = b;
      k++;
    }
    a = mp[a];
    b = mp[b];
    C[a]++;
    C[b]++;
    E[a].push_back(b);
    E[b].push_back(a);
  }
  ss = 0;
  for (i = 0; i < k; i++)
    if (C[i] == 1) {
      ss = i;
      break;
    }
  dfs(ss, -1);
  return 0;
}
