记录
code
#include <bits/stdc++.h>
using namespace std;
#define hh putchar('\n')
#define kg putchar(' ')
#define debug puts("debug")
namespace quickread{
inline int read(){
int x=0,f=1;char ch=getchar();
while (ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while (ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
return x*f;
}
inline void write(int x){
if(x<0){putchar('-');x=-x;}
if(x>9)write(x/10);
putchar(x%10+'0');
}
inline string readstr(){
char ch=getchar();string str="";
while(!(ch>='0'&&ch<='9')&&!(ch>='a'&&ch<='z')&&!(ch>='A'&&ch<='Z')) ch=getchar();
while((ch>='0'&&ch<='9')||(ch>='a'&&ch<='z')||(ch>='A'&&ch<='Z')){str+=ch;ch=getchar();}
return str;
}
inline char readchar(){
char ch=getchar();
while(!(ch>='0'&&ch<='9')&&!(ch>='a'&&ch<='z')&&!(ch>='A'&&ch<='Z')) ch=getchar();
return ch;
}
}
using namespace quickread;
int n,m,bg,top,st[100010];
vector<int> p[510];
vector<int>::iterator it[100010];
bool vis[510][510];
void hierholzers(){
for(int i=1;i<=n;i++){
int d=p[i].size();
if(d%2==1) {bg=i;break;}
}
for(int i=1;i<=n;i++){
sort(p[i].begin(),p[i].end());
it[i]=p[i].begin();
}
if(!bg){
bg=510;
for(int i=1;i<=n;i++)
if(p[i].size()&&bg>i) bg=i;
}
}
void dfs(int u){
while(it[u]!=p[u].end()){
int v=*it[u];it[u]++;
if(vis[u][v]) continue;
vis[u][v]=vis[v][u]=1;
dfs(v);
}
st[++top]=u;
}
signed main(){
m=read();
for(int i=1;i<=m;i++){
int u=read(),v=read();
p[u].push_back(v);
p[v].push_back(u);
n=max(n,max(u,v));
}
hierholzers();
dfs(bg);
for(int i=top;i>=1;i--) write(st[i]),hh;;
return 0;
}