#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5e5 + 5;
const int MAXM = 4e7 + 5;
const int MOD = 998244353;
vector<int> v[MAXN], g;
bool vis[MAXN];
int main() {
  int n;
  while (~scanf("%d", &n)) {
    for (int i = 1; i <= n; i++) v[i].clear();
    g.clear();
    for (int i = 1; i <= n; i++) {
      int x, y;
      scanf("%d%d", &x, &y);
      v[i].push_back(x), v[i].push_back(y);
    }
    if (n == 3) {
      cout << "1 2 3" << endl;
      continue;
    }
    memset(vis, 0, sizeof(vis));
    int pos = 1;
    vis[1] = 1;
    g.push_back(1);
    while (1) {
      int x = v[pos][0], y = v[pos][1];
      if (v[x][0] == y || v[x][1] == y) {
        if (vis[x]) break;
        g.push_back(x);
        pos = x;
      } else {
        if (vis[y]) break;
        g.push_back(y);
        pos = y;
      }
    }
    for (int i = 0; i <= n - 1; i++) {
      printf("%d ", g[i]);
    }
    puts("");
  }
}
