/* * Author: $%U%$ * Time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$ */ #include using namespace std; typedef long long ll; #define rep(i,a,b) for(ll i=(a);i<=(b);i++) #define per(i,a,b) for(ll i=(a);i>=(b);i--) #define re(i,a,b) for(ll i=(a);i<(b);i++) #define pe(i,a,b) for(ll i=(a);i>(b);i--) #define getchar()(p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++) char buf[1<<21],*p1=buf,*p2=buf; template inline void read(T& r) { r=0;bool w=0; char ch=getchar(); while(ch<'0'||ch>'9') w=ch=='-'?1:0,ch=getchar(); while(ch>='0'&&ch<='9') r=r*10+(ch^48), ch=getchar(); r=w?-r:r; } template inline void readupp(T& r){ r=0; char ch=getchar(); while(ch>'Z'||ch<'A')ch=getchar(); r=ch; } template inline void readlow(T& r){ r=0; char ch=getchar(); while(ch>'z'||ch<'a')ch=getchar(); r=ch; } template inline void readdig(T& r){ r=0; char ch=getchar(); while(ch>'9'||ch<'0')ch=getchar(); r=ch-'0'; } template inline void readvisi(T& r){ r=0; char ch=getchar(); while(ch>126||ch<33)ch=getchar(); r=ch; } template inline ll readlowstr(T& r){ ll n=0; char ch=getchar(); while(ch>'z'||ch<'a')ch=getchar(); while(ch<='z'&&ch>='a')r[++n]=ch-'a',ch=getchar(); return n; } template inline ll readuppstr(T& r){ ll n=0; char ch=getchar(); while(ch>'Z'||ch<'A')ch=getchar(); while(ch<='Z'&&ch>='A')r[++n]=ch-'A',ch=getchar(); return n; } template inline ll readdigstr(T& r){ ll n=0; char ch=getchar(); while(ch>'9'||ch<'0')ch=getchar(); while(ch<='9'&&ch>='0')r[++n]=ch-'0',ch=getchar(); return n; } template inline ll readvisistr(T& r){ ll n=0; char ch=getchar(); while(ch>126||ch<33)ch=getchar(); while(ch<=126&&ch>=33)r[++n]=ch,ch=getchar(); return n; } const ll MOD=998244353; ll gcd(ll A,ll B){return B?gcd(B,A%B):A;} template void chkmax(T&A,T B){if(A void chkmin(T&A,T B){if(A>B)A=B;} template T Madd(T A,T B){return A+B>=MOD?A+B-MOD:A+B;} template T Msub(T A,T B){return A-B<0?A-B+MOD:A-B;} template void MODed(T &A){A%=MOD;A+=(A<0?MOD:0);} ll pw(ll A,ll B){ ll res=1; while(B){ if(B&1)res=res*A%MOD; A=A*A%MOD; B>>=1; } return res; } void _FILE(string s){ freopen((s+".in").c_str(),"r",stdin); freopen((s+".out").c_str(),"w",stdout); } const ll N=200003,M=3003,INF=2000000000000000007ll; ll n,X,q,id[N],dis[N],sz[N][31][2],Sz[N]; ll find(ll x){ if(x==id[x])return x; ll er=find(id[x]); dis[x]^=dis[id[x]]; return id[x]=er; } int main(){ read(n),read(X),read(q); re(i,0,n)id[i]=i; re(i,0,n)rep(j,0,29)sz[i][j][0]=1,dis[i]=0; rep(i,1,q){ ll in1,in2,in3; read(in1); if(in1==1){ read(in2),read(in3); find(in2); in3^=dis[in2]; in2=find(in2); ll P=find(X); in3^=dis[X]; Sz[in2]=Sz[P]+Sz[in2]; rep(j,0,29){ bool k=(in3&(1<