#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const int lgN = 1e6 + 5;
const int te = 3e8 + 1;
const long long int MOD = 998244353;
const long double pi = 3.141592653589793238462643383;
const long long int IMAX = LLONG_MAX;
const double PI = 3.141592653589793;
template <class T>
using max_pq = priority_queue<T>;
template <class T>
using min_pq = priority_queue<T, vector<T>, greater<T>>;
long long int x, y;
template <class T>
T gcd(T a, T b) {
  if (a == 0) {
    x = 0, y = 1;
    return b;
  }
  T gc = gcd(b % a, a);
  T temp;
  temp = x;
  x = y - (b / a) * temp;
  y = temp;
  return gc;
}
long long int po(long long int a, long long int x, long long int m) {
  if (x == 0) {
    return 1;
  }
  long long int ans = 1;
  long long int k = 1;
  while (k <= x) {
    if (x & k) {
      ans = ((ans * a) % m);
    }
    k <<= 1;
    a *= a;
    a %= m;
  }
  return ans;
}
long long int countSetBits(long long int n) {
  long long int count = 0;
  while (n) {
    n &= (n - 1);
    count++;
  }
  return count;
}
long long int n;
vector<long long int> check(long long int a, long long int b,
                            vector<vector<long long int>> &v) {
  vector<long long int> ans;
  ans.push_back(a);
  ans.push_back(b);
  long long int i;
  for (i = int(1); i <= int(n - 2); i++) {
    long long int x = v[a][0];
    long long int y = v[a][1];
    if (x == b) {
      ans.push_back(y);
      a = b;
      b = y;
    } else if (y == b) {
      ans.push_back(x);
      a = b;
      b = x;
    } else {
      return ans;
    }
  }
  return ans;
}
int main() {
  cin >> n;
  vector<vector<long long int>> v(n + 1, vector<long long int>(2, 0));
  long long int i;
  for (i = int(1); i <= int(n); i++) {
    long long int a;
    long long int b;
    cin >> a >> b;
    v[i][0] = a;
    v[i][1] = b;
  }
  vector<long long int> x = check(1, v[1][0], v);
  vector<long long int> y = check(1, v[1][1], v);
  if (x.size() == n) {
    for (i = int(0); i <= int(n - 1); i++) cout << x[i] << " ";
  } else {
    for (i = int(0); i <= int(n - 1); i++) cout << y[i] << " ";
  }
}
