#include<bits/stdc++.h>
using namespace std;
int ll[10005];
int main(){
int type;
int q;
cin>>q;
ll[0]=1;
int x,y;
int tr;
for(int i=0;i<q;++i){
cin>>type;
if(type==1){
cin>>x>>y;
tr=ll[x];
ll[y]=tr;
ll[x]=y;
}
if(type==2){
cin>>x;
cout<<ll[x];
}
if(type==3){
cin>>x;
ll[x]=ll[ll[x]];
}
}
return 0;
}
WA+RE 0分 求助