#include <bits/stdc++.h>   using namespace std;   long long gcd(long long b, long long y) { return b > 0 ? gcd(y % b, b) : y; }   long long lcm(long long b, long long y) { return b * y / gcd(b, y); }   double dis(double x1, double x2, double y1, double y2) {     double ans = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);     return sqrt(ans);   }   double random(double start, double en) {     return start + (en - start) * rand() / (RAND_MAX + 1.0);   }   map<int, vector<int> > a;   map<int, int> b;   map<int, vector<int> >::iterator it;   void dfs(int x) {     if (b[x]) return;     b[x] = 1;     cout << x <<    ;     for (int i = 0; i < a[x].size(); i++) {       dfs(a[x][i]);     }     return;   }   int main() {     int n;     while (cin >> n) {       for (int i = 1; i <= n; i++) {         int x, y;         cin >> x >> y;         a[x].push_back(y);         a[y].push_back(x);       }       int t;       for (it = a.begin(); it != a.end(); it++) {         if (it->second.size() == 1) {           t = it->first;           break;         }       }       dfs(t);     }   }   