#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 6;
int x[N], edge[N], bedge[N], used[N];
vector<int> s;
int main() {
  int n;
  scanf("%d", &n);
  set<int> st;
  for (int i = 0; i < n; ++i) {
    int a, b;
    scanf("%d %d", &a, &b);
    edge[a] = b;
    bedge[b] = a;
    if (a) st.insert(a);
    if (b) st.insert(b);
  }
  int u = 0, pos = 0;
  while (1) {
    u = edge[u];
    if (!st.count(u)) break;
    st.erase(u);
    pos += 2;
    x[pos] = u;
  }
  u = *st.begin();
  deque<int> dq;
  dq.emplace_back(u);
  st.erase(u);
  int v = u;
  while (1) {
    v = bedge[v];
    if (!st.count(v)) break;
    st.erase(v);
    dq.push_front(v);
  }
  v = u;
  while (1) {
    v = edge[v];
    if (!st.count(v)) break;
    st.erase(v);
    dq.push_back(v);
  }
  for (int i = 1, j = 0; j < (int)dq.size(); i += 2, j++) x[i] = dq[j];
  for (int i = 1; i <= n; ++i) printf("%d%c", x[i], " \n"[i == n]);
}
