https://codeforces.com/contest/1095/problem/D
ll n,m,q,cnt,f,res,cnt1;
ll cha;
string s;
ll a[maxn],b[maxn];
int vis[maxn];
pii p[maxn];
bool check(int now,int f,int s){
if(vis[f])
return false;
if(p[f].fi==s || p[f].se==s) //f后跟s 存在
return true;
return false;
}
int main(){
cin>>n;
rep(i,1,n){
cin>>p[i].fi>>p[i].se;
}
int now=1;
rep(i,1,n){ //第一个1 第n个是n
cout<<now<<' ';
vis[now]=1;
if(check(now,p[now].fi,p[now].se))
now=p[now].fi; //now后跟第一个可以 不是跟第一个就是跟第二个
else
now=p[now].se;
}
cout<<endl;
return 0;
}