#include<bits/stdc++.h>
#define ll long long
#define ntr "\n"
#define mod (ll)(1e9+7)
#define taskname "temp"
#define frep freopen("input.inp","r",stdin); freopen(taskname".out","w",stdout);
using namespace std;
struct node{
ll child[2];
ll cnt;
};
struct vert{
ll child,type,val;
};
node trie[3000009];
ll ans[100001];
vector<vert> adj[100001];
vector<ll> avail;
ll n,q,nn=0;
ll newnode(){
if(avail.size()){
ll pos=avail.back();
avail.pop_back();
trie[pos].child[0]=trie[pos].child[1]=trie[pos].cnt=0;
return pos;
}
else{
nn++;
trie[nn].child[0]=trie[nn].child[1]=trie[nn].cnt=0;
return nn;
}
}
void add(ll num){
ll pos=0;
for(int i=29;i>=0;i--){
if(num&(1<<i)){
if(trie[pos].child[1]==0){
trie[pos].child[1]=newnode();
}
pos=trie[pos].child[1];
trie[pos].cnt++;
}
else{
if(trie[pos].child[0]==0){
trie[pos].child[0]=newnode();
}
pos=trie[pos].child[0];
trie[pos].cnt++;
}
}
}
bool del(ll id,ll num,ll pos){
if(id>=0){
if(num&(1<<id)){
if(del(id-1,num,trie[pos].child[1])) trie[pos].child[1]=0;
}
else{
if(del(id-1,num,trie[pos].child[0])) trie[pos].child[0]=0;
}
}
trie[pos].cnt--;
if(trie[pos].cnt==0){
avail.push_back(pos);
return true;
}
return false;
}
ll get(ll num){
ll pos=0,ans=0;
for(int i=29;i>=0;i--){
if(num&(1<<i)){
if(trie[pos].child[1]){
pos=trie[pos].child[1];
}
else{
ans|=(1<<i);
pos=trie[pos].child[0];
}
}
else{
if(trie[pos].child[0]){
pos=trie[pos].child[0];
}
else{
ans|=(1<<i);
pos=trie[pos].child[1];
}
}
}
return ans;
}
void trav(ll u,ll num){
for(auto v:adj[u]){
if(v.type==1){
ans[v.child]=min(ans[u],v.val);
add(num^v.val);
trav(v.child,num);
del(29,num^v.val,0);
}
else{
ans[v.child]=get(num^v.val);
trav(v.child,num^v.val);
}
}
}
int main(){
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
//frep;
trie[0].child[0]=trie[0].child[1]=trie[0].cnt=0;
cin>>n>>q;
ans[0]=1e18;
for(int i=0;i<n;i++){
ll x;
cin>>x;
ans[0]=min(ans[0],x);
add(x);
}
for(int i=1;i<=q;i++){
ll type,u,num;
cin>>type>>u>>num;
adj[u].push_back({i,type,num});
}
trav(0,0);
for(int i=0;i<=q;i++){
cout<<ans[i]<<' ';
}
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KI2RlZmluZSBsbCBsb25nIGxvbmcKI2RlZmluZSBudHIgIlxuIgojZGVmaW5lIG1vZCAobGwpKDFlOSs3KQojZGVmaW5lIHRhc2tuYW1lICJ0ZW1wIgojZGVmaW5lIGZyZXAgZnJlb3BlbigiaW5wdXQuaW5wIiwiciIsc3RkaW4pOyBmcmVvcGVuKHRhc2tuYW1lIi5vdXQiLCJ3IixzdGRvdXQpOwp1c2luZyBuYW1lc3BhY2Ugc3RkOwpzdHJ1Y3Qgbm9kZXsKICAgIGxsIGNoaWxkWzJdOwogICAgbGwgY250Owp9OwpzdHJ1Y3QgdmVydHsKICAgIGxsIGNoaWxkLHR5cGUsdmFsOwp9Owpub2RlIHRyaWVbMzAwMDAwOV07CmxsIGFuc1sxMDAwMDFdOwp2ZWN0b3I8dmVydD4gYWRqWzEwMDAwMV07CnZlY3RvcjxsbD4gYXZhaWw7CmxsIG4scSxubj0wOwpsbCBuZXdub2RlKCl7CiAgICBpZihhdmFpbC5zaXplKCkpewogICAgICAgIGxsIHBvcz1hdmFpbC5iYWNrKCk7CiAgICAgICAgYXZhaWwucG9wX2JhY2soKTsKICAgICAgICB0cmllW3Bvc10uY2hpbGRbMF09dHJpZVtwb3NdLmNoaWxkWzFdPXRyaWVbcG9zXS5jbnQ9MDsKICAgICAgICByZXR1cm4gcG9zOwogICAgfQogICAgZWxzZXsKICAgICAgICBubisrOwogICAgICAgIHRyaWVbbm5dLmNoaWxkWzBdPXRyaWVbbm5dLmNoaWxkWzFdPXRyaWVbbm5dLmNudD0wOwogICAgICAgIHJldHVybiBubjsKICAgIH0KfQp2b2lkIGFkZChsbCBudW0pewogICAgbGwgcG9zPTA7CiAgICBmb3IoaW50IGk9Mjk7aT49MDtpLS0pewogICAgICAgIGlmKG51bSYoMTw8aSkpewogICAgICAgICAgICBpZih0cmllW3Bvc10uY2hpbGRbMV09PTApewogICAgICAgICAgICAgICAgdHJpZVtwb3NdLmNoaWxkWzFdPW5ld25vZGUoKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBwb3M9dHJpZVtwb3NdLmNoaWxkWzFdOwogICAgICAgICAgICB0cmllW3Bvc10uY250Kys7CiAgICAgICAgfQogICAgICAgIGVsc2V7CiAgICAgICAgICAgIGlmKHRyaWVbcG9zXS5jaGlsZFswXT09MCl7CiAgICAgICAgICAgICAgICB0cmllW3Bvc10uY2hpbGRbMF09bmV3bm9kZSgpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHBvcz10cmllW3Bvc10uY2hpbGRbMF07CiAgICAgICAgICAgIHRyaWVbcG9zXS5jbnQrKzsKICAgICAgICB9CiAgICB9Cn0KYm9vbCBkZWwobGwgaWQsbGwgbnVtLGxsIHBvcyl7CiAgICBpZihpZD49MCl7CiAgICAgICAgaWYobnVtJigxPDxpZCkpewogICAgICAgICAgICBpZihkZWwoaWQtMSxudW0sdHJpZVtwb3NdLmNoaWxkWzFdKSkgdHJpZVtwb3NdLmNoaWxkWzFdPTA7CiAgICAgICAgfQogICAgICAgIGVsc2V7CiAgICAgICAgICAgIGlmKGRlbChpZC0xLG51bSx0cmllW3Bvc10uY2hpbGRbMF0pKSB0cmllW3Bvc10uY2hpbGRbMF09MDsKICAgICAgICB9CiAgICB9CiAgICB0cmllW3Bvc10uY250LS07CiAgICBpZih0cmllW3Bvc10uY250PT0wKXsKICAgICAgICBhdmFpbC5wdXNoX2JhY2socG9zKTsKICAgICAgICByZXR1cm4gdHJ1ZTsKICAgIH0KICAgIHJldHVybiBmYWxzZTsKfQpsbCBnZXQobGwgbnVtKXsKICAgIGxsIHBvcz0wLGFucz0wOwogICAgZm9yKGludCBpPTI5O2k+PTA7aS0tKXsKICAgICAgICBpZihudW0mKDE8PGkpKXsKICAgICAgICAgICAgaWYodHJpZVtwb3NdLmNoaWxkWzFdKXsKICAgICAgICAgICAgICAgIHBvcz10cmllW3Bvc10uY2hpbGRbMV07CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZWxzZXsKICAgICAgICAgICAgICAgIGFuc3w9KDE8PGkpOwogICAgICAgICAgICAgICAgcG9zPXRyaWVbcG9zXS5jaGlsZFswXTsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBlbHNlewogICAgICAgICAgICBpZih0cmllW3Bvc10uY2hpbGRbMF0pewogICAgICAgICAgICAgICAgcG9zPXRyaWVbcG9zXS5jaGlsZFswXTsKICAgICAgICAgICAgfQogICAgICAgICAgICBlbHNlewogICAgICAgICAgICAgICAgYW5zfD0oMTw8aSk7CiAgICAgICAgICAgICAgICBwb3M9dHJpZVtwb3NdLmNoaWxkWzFdOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgfQogICAgcmV0dXJuIGFuczsKfQp2b2lkIHRyYXYobGwgdSxsbCBudW0pewogICAgZm9yKGF1dG8gdjphZGpbdV0pewogICAgICAgIGlmKHYudHlwZT09MSl7CiAgICAgICAgICAgIGFuc1t2LmNoaWxkXT1taW4oYW5zW3VdLHYudmFsKTsKICAgICAgICAgICAgYWRkKG51bV52LnZhbCk7CiAgICAgICAgICAgIHRyYXYodi5jaGlsZCxudW0pOwogICAgICAgICAgICBkZWwoMjksbnVtXnYudmFsLDApOwogICAgICAgIH0KICAgICAgICBlbHNlewogICAgICAgICAgICBhbnNbdi5jaGlsZF09Z2V0KG51bV52LnZhbCk7CiAgICAgICAgICAgIHRyYXYodi5jaGlsZCxudW1edi52YWwpOwogICAgICAgIH0KICAgIH0KfQppbnQgbWFpbigpewogICAgaW9zX2Jhc2U6OnN5bmNfd2l0aF9zdGRpbyhmYWxzZSk7IGNpbi50aWUoMCk7IGNvdXQudGllKDApOwogICAgLy9mcmVwOwogICAgdHJpZVswXS5jaGlsZFswXT10cmllWzBdLmNoaWxkWzFdPXRyaWVbMF0uY250PTA7CiAgICBjaW4+Pm4+PnE7CiAgICBhbnNbMF09MWUxODsKICAgIGZvcihpbnQgaT0wO2k8bjtpKyspewogICAgICAgIGxsIHg7CiAgICAgICAgY2luPj54OwogICAgICAgIGFuc1swXT1taW4oYW5zWzBdLHgpOwogICAgICAgIGFkZCh4KTsKICAgIH0KICAgIGZvcihpbnQgaT0xO2k8PXE7aSsrKXsKICAgICAgICBsbCB0eXBlLHUsbnVtOwogICAgICAgIGNpbj4+dHlwZT4+dT4+bnVtOwogICAgICAgIGFkalt1XS5wdXNoX2JhY2soe2ksdHlwZSxudW19KTsKICAgIH0KICAgIHRyYXYoMCwwKTsKICAgIGZvcihpbnQgaT0wO2k8PXE7aSsrKXsKICAgICAgICBjb3V0PDxhbnNbaV08PCcgJzsKICAgIH0KfQo=