#include <bits/stdc++.h>   using namespace std;   int n = 0, s = 0, d = 0;   map<int, vector<int> > graph;   map<int, bool> vis;   bool stop = false;   void Dfs(int m) {     if (m == d || stop) {       cout << m;       stop = true;       return;     }     cout << m <<    ;     for (int i = 0; i < (int)graph[m].size(); i++) {       if (vis.find(graph[m][i]) == vis.end()) {         vis[graph[m][i]] = true;         Dfs(graph[m][i]);       }     }   }   int main() {     cin >> n;     for (int i = 0; i < n; i++) {       cin >> s >> d;       graph[s].push_back(d);       graph[d].push_back(s);     }     vector<int> k;     for (map<int, vector<int> >::iterator it = graph.begin(); it != graph.end();          it++) {       if ((*it).second.size() == 1) {         k.push_back((*it).first);       }     }     s = k[0], d = k[1];     vis[s] = true;     Dfs(s);     return 0;   }   