#include <bits/stdc++.h>
using namespace std;
template <class F, class T>
T convert(F a, int p = -1) {
  stringstream ss;
  if (p >= 0) ss << fixed << setprecision(p);
  ss << a;
  T r;
  ss >> r;
  return r;
}
template <class T>
T gcd(T a, T b) {
  T r;
  while (b != 0) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}
template <class T>
T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
template <class T>
T sqr(T x) {
  return x * x;
}
template <class T>
T cube(T x) {
  return x * x * x;
}
template <class T>
int getbit(T s, int i) {
  return (s >> i) & 1;
}
template <class T>
T onbit(T s, int i) {
  return s | (T(1) << i);
}
template <class T>
T offbit(T s, int i) {
  return s & (~(T(1) << i));
}
template <class T>
int cntbit(T s) {
  return s == 0 ? 0 : cntbit(s >> 1) + (s & 1);
}
const long double PI = acos(-1.0);
const long double eps = 1e-9;
const int dr[] = {-1, 0, +1, 0};
const int dc[] = {0, +1, 0, -1};
const int inf = (int)1e9 + 5;
const long long linf = (long long)1e16 + 5;
const long long mod = (long long)1e9 + 7;
int sau[1000006];
int tr[1000006];
int kq[1000006];
bool tt[1000006];
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  int x, y;
  memset(kq, -1, sizeof(kq));
  memset(tr, -1, sizeof(tr));
  memset(sau, -1, sizeof(sau));
  memset(tt, 0, sizeof(tt));
  for (int i = (1); i <= (n); ++i) {
    cin >> x >> y;
    tt[x] = 1;
    tt[y] = 1;
    sau[x] = y;
    tr[y] = x;
  }
  for (int i = (1); i <= (int(1e6)); ++i) {
    if (tt[i] && tr[i] == -1) {
      kq[1] = i;
      break;
    }
  }
  kq[0] = 0;
  for (int i = (2); i <= (n); ++i) {
    kq[i] = sau[kq[i - 2]];
  }
  for (int i = (1); i <= (n); ++i) {
    cout << kq[i] << " ";
  }
}
