#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
const int maxn=100010;
struct node
{
int ls,rs,sum;
}s[maxn*200];
int n,m,cnt,tot,root,mn,ans;
int to[maxn<<1],next[maxn<<1],head[maxn],v[maxn],fa[maxn],siz[maxn],r1[maxn],r2[maxn],vis[maxn],Log[maxn<<1];
int md[20][maxn<<1],pos[maxn],dep[maxn];
void getrt(int x,int fa)
{
siz[x]=1;
int i,tmp=0;
for(i=head[x];i!=-1;i=next[i]) if(!vis[to[i]]&&to[i]!=fa)
getrt(to[i],x),siz[x]+=siz[to[i]],tmp=max(tmp,siz[to[i]]);
tmp=max(tmp,tot-siz[x]);
if(tmp<mn) root=x,mn=tmp;
}
void solve(int x)
{
vis[x]=1;
for(int i=head[x];i!=-1;i=next[i]) if(!vis[to[i]]) tot=siz[to[i]],mn=1<<30,getrt(to[i],x),fa[root]=x,solve(root);
}
void dfs(int x)
{
md[0][++pos[0]]=dep[x],pos[x]=pos[0];
for(int i=head[x];i!=-1;i=next[i]) if(!dep[to[i]]) dep[to[i]]=dep[x]+1,dfs(to[i]),md[0][++pos[0]]=dep[x];
}
inline void add(int a,int b)
{
to[cnt]=b,next[cnt]=head[a],head[a]=cnt++;
}
inline int getmin(int a,int b)
{
if(a>b) swap(a,b);
int k=Log[b-a+1];
return min(md[k][a],md[k][b-(1<<k)+1]);
}
inline int dis(int a,int b)
{
return dep[a]+dep[b]-2*getmin(pos[a],pos[b]);
}
void updata(int l,int r,int &x,int a,int b)
{
if(!x) x=++tot;
s[x].sum+=b;
if(l==r) return ;
int mid=(l+r)>>1;
if(a<=mid) updata(l,mid,s[x].ls,a,b);
else updata(mid+1,r,s[x].rs,a,b);
}
int query(int l,int r,int x,int a,int b)
{
if(!x||a>b) return 0;
if(a<=l&&r<=b) return s[x].sum;
int mid=(l+r)>>1;
if(b<=mid) return query(l,mid,s[x].ls,a,b);
if(a>mid) return query(mid+1,r,s[x].rs,a,b);
return query(l,mid,s[x].ls,a,b)+query(mid+1,r,s[x].rs,a,b);
}
inline char nc(){
static char buf[100000],*p1=buf,*p2=buf;
return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
inline int rd(){
char ch=nc();int sum=0;
while(!(ch>=‘0‘&&ch<=‘9‘))ch=nc();
while(ch>=‘0‘&&ch<=‘9‘)sum=sum*10+ch-48,ch=nc();
return sum;
}
int main()
{
//freopen("bz3730.in","r",stdin);
//freopen("bz3730.out","w",stdout);
n=rd(),m=rd();
int a,b,c;
register int i,j,x,y;
memset(head,-1,sizeof(head));
for(i=1;i<=n;i++) v[i]=rd();
for(i=1;i<n;i++) a=rd(),b=rd(),add(a,b),add(b,a);
dep[1]=1,dfs(1),tot=n,mn=1<<30,getrt(1,0),solve(root);
for(i=2;i<=pos[0];i++) Log[i]=Log[i>>1]+1;
for(j=1;(1<<j)<=pos[0];j++) for(i=1;i+(1<<j)-1<=pos[0];i++) md[j][i]=min(md[j-1][i],md[j-1][i+(1<<(j-1))]);
tot=0;
for(i=1;i<=n;i++)
{
x=i;
while(x)
{
y=fa[x],updata(0,n,r1[x],dis(x,i),v[i]);
if(y) updata(0,n,r2[x],dis(y,i),v[i]);
x=y;
}
}
for(i=1;i<=m;i++)
{
c=rd(),a=rd()^ans,b=rd()^ans;
if(!c)
{
ans=0,x=a;
while(x)
{
y=fa[x],ans+=query(0,n,r1[x],0,b-dis(x,a));
if(y) ans-=query(0,n,r2[x],0,b-dis(y,a));
x=y;
}
printf("%d\n",ans);
}
else
{
x=a;
while(x)
{
y=fa[x],updata(0,n,r1[x],dis(x,a),b-v[a]);
if(y) updata(0,n,r2[x],dis(y,a),b-v[a]);
x=y;
}
v[a]=b;
}
}
return 0;
}