#include<bits/stdc++.h>
using namespace std;
int read()
{
int f=1,x=0; char c=getchar();
while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
while(isdigit(c)){x=(x<<1)+(x<<3)+(c^48);c=getchar();}
return f*x;
}
void write(int x)
{
if(x<0){putchar('-');x=-x;}
if(x>9) write(x/10);
putchar(x%10+'0');
}
const int N=200010;
int n,q,a[N];
int head[N],cn;
struct edge
{
int nxt,to;
}e[N<<1];
void add(int u,int v)
{
cn++;
e[cn].nxt=head[u];
e[cn].to=v;
head[u]=cn;
}
int fa[N],dep[N],siz[N],son[N];
int top[N],id[N],bb[N],tot;
void dfs1(int u,int d,int f)
{
dep[u]=d; fa[u]=f; siz[d]=1;
for(int i=head[u];i;i=e[i].nxt)
{
int v=e[i].to;
if(v==f) continue;
dfs1(v,d+1,u);
siz[u]+=siz[v];
if(siz[v]>siz[son[u]]) son[u]=v;
}
}
void dfs2(int u,int t)
{
top[u]=t; id[u]=++tot; bb[tot]=a[u];
if(!son[u]) return;
dfs2(son[u],t);
for(int i=head[u];i;i=e[i].nxt)
{
int v=e[i].to;
if(v==son[u]||v==fa[u]) continue;
dfs2(v,v);
}
}
int cnode,rt[N],ch[N*30][2],cnt[N*30];
void split(int x){
for(int i=0;i<=30;i++){
b[i]=x&1;x>>=1;
}
}
void update(int pre,int now){
for(int i=30;i>=0;i--){
ch[now][b[i]]=++cnt;
ch[now][b[i]^1]=ch[pre][b[i]^1];
now=ch[now][b[i]];pre=ch[pre][b[i]];
sum[now]=sum[pre]+1;
}
}
int query(int u,int v){
int ans=0;
for(int i=30;i>=0;i--){
ans<<=1;
if(sum[ch[v][b[i]^1]]-sum[ch[u][b[i]^1]]>0){
ans|=1;
v=ch[v][b[i]^1];u=ch[u][b[i]^1];
}
else {
v=ch[v][b[i]];u=ch[u][b[i]];
}
}
return ans;
}
int getans(int x,int y,int z)
{
int ans=0;
while(top[x]!=top[y])
{
if(dep[top[x]]<dep[top[y]]) swap(x,y);
ans=max(ans,query(rt[id[top[x]]-1],rt[id[x]],30,z));
x=fa[top[x]];
}
if(dep[x]>dep[y]) swap(x,y);
ans=max(ans,query(rt[id[x]-1],rt[id[y]],30,z));
return ans;
}
int main()
{
n=read(),q=read();
for(int i=1;i<=n;i++) a[i]=read();
for(int i=1;i<n;i++)
{
int u=read(),v=read();
add(u,v); add(v,u);
}
dfs1(1,1,0); dfs2(1,1);
for(int i=1;i<=n;i++)
{
rt[i]=cnode++;
update(rt[i],rt[i-1],30,b[i]);
}
while(q--)
{
int opt=read();
if(opt==1)
{
int x=read(),z=read();
write(query(rt[id[x]-1],rt[id[x]+siz[x]-1],30,z));
puts("");
}
else
{
int x=read(),y=read(),z=read();
write(getans(x,y,z));
puts("");
}
}
return 0;
}