#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long int LINF = 0x3f3f3f3f3f3f3f3fll;
const long double pi = acos(-1);
const int MOD = 1e9 + 7;
const int N = 1e6 + 10;
int tras[N], frente[N];
int n;
int main() {
  scanf("%d", &n);
  if (n & 1) {
    memset(tras, -1, sizeof(tras));
    memset(frente, -1, sizeof(frente));
    for (int i = 0; i < n; i++) {
      int u, v;
      scanf("%d%d", &u, &v);
      tras[u] = v;
      frente[v] = u;
    }
    vector<int> par, impar;
    int b = 0;
    while (true) {
      b = tras[b];
      if (b == -1 or b == 0) break;
      par.push_back(b);
    }
    b = 0;
    for (int i = 1; i < N; i++)
      if (tras[i] == -1 and frente[i] != -1) b = i;
    if (b != 0) impar.push_back(b);
    while (true) {
      b = frente[b];
      if (b == -1 or b == 0) break;
      impar.push_back(b);
    }
    reverse(impar.begin(), impar.end());
    int x = 0;
    bool p = false;
    while (true) {
      if (p) {
        if (x == par.size()) break;
        cout << par[x++] << " ";
      } else {
        if (x == impar.size()) break;
        cout << impar[x] << " ";
      }
      p = !p;
    }
  } else {
    for (int i = 0; i < n; i++) {
      int u, v;
      scanf("%d%d", &u, &v);
      tras[u] = v;
      frente[v] = u;
    }
    vector<int> par, impar;
    int b = 0;
    while (true) {
      if (tras[b] == 0) break;
      b = tras[b];
      par.push_back(b);
    }
    b = 0;
    while (true) {
      if (frente[b] == 0) break;
      b = frente[b];
      impar.push_back(b);
    }
    reverse(impar.begin(), impar.end());
    int x = 0;
    bool p = false;
    while (true) {
      if (p) {
        if (x == par.size()) break;
        cout << par[x++] << " ";
      } else {
        if (x == impar.size()) break;
        cout << impar[x] << " ";
      }
      p = !p;
    }
  }
  cout << endl;
  return 0;
}
