#include <bits/stdc++.h>
using namespace std;
const int Maxn = 200000 + 10;
const int Maxm = 1000000 + 10;
int n;
int f, s;
int front[Maxm];
short int mark[Maxm];
void input();
void output();
int main() {
  input();
  output();
  return 0;
}
void input() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    front[a] = b;
    mark[b] = 2;
    if (mark[a] != 2) mark[a] = 1;
  }
}
void output() {
  for (int i = 1; i <= 1000000; i++)
    if (mark[i] == 1) f = i;
  s = front[0];
  for (int i = 1; i <= n; i++) {
    if (f != 0) cout << f << " ";
    int k = s;
    s = front[f];
    f = k;
  }
}
