#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <math.h>
using namespace std;
#define N 100050
typedef unsigned long long ll;
int size,block,L[N],R[N],pos[N],n,m;
int dep[N],fa[N],head[N],to[N<<1],nxt[N<<1],val[N],cnt,root,poi[N][350],dfn[N],son[N];
ll sum[N],tag[N],s[N],c[N];
inline void add(int u,int v) {
to[++cnt]=v; nxt[cnt]=head[u]; head[u]=cnt;
}
void fix(int x,ll v) {
for(;x<=n;x+=x&(-x)) c[x]+=v;
}
ll inq(int x) {
ll re=0;
for(;x;x-=x&(-x)) re+=c[x]; return re;
}
void dfs(int x,int y) {
int i,j; fa[x]=y; dep[x]=dep[y]+1; sum[x]=val[x]; dfn[x]=++dfn[0];
poi[x][pos[x]]++;
for(i=head[x];i;i=nxt[i]) {
if(to[i]!=y) {
for(j=1;j<=block;j++) poi[to[i]][j]=poi[x][j];
dfs(to[i],x);
sum[x]+=sum[to[i]];
}
}
son[x]=dfn[0];
}
void modify(int x,int y) {
int i;
for(i=1;i<=block;i++) tag[i]+=1ll*y*poi[x][i];
}
ll query(int x,int y) {
int p=pos[x],q=pos[y],i;
ll ans=0;
if(p==q) {
for(i=x;i<=y;i++) ans+=inq(son[i])-inq(dfn[i]-1);
}else {
for(i=p+1;i<q;i++) ans+=s[i]+tag[i];
for(i=x;i<=R[p];i++) {
ans+=inq(son[i])-inq(dfn[i]-1);
}
for(i=L[q];i<=y;i++) {
ans+=inq(son[i])-inq(dfn[i]-1);
}
}
return ans;
}
int main() {
scanf("%d%d",&n,&m);
int i,x,y,opt,j;
size=sqrt(n);
block=n/size;
for(i=1;i<=block;i++) {
L[i]=R[i-1]+1; R[i]=size*i;
for(j=L[i];j<=R[i];j++) {
pos[j]=i;
}
}
if(R[block]!=n) {
block++; L[block]=R[block-1]+1; R[block]=n;
for(i=L[block];i<=n;i++) pos[i]=block;
}
for(i=1;i<=n;i++) scanf("%d",&i[val]);
for(i=1;i<=n;i++) {
scanf("%d%d",&x,&y);
if(x) {
add(x,y); add(y,x);
}else root=y;
}
dfs(root,0);
for(i=1;i<=n;i++) s[pos[i]]+=sum[i],fix(dfn[i],val[i]);
while(m--) {
scanf("%d%d%d",&opt,&x,&y);
if(opt==1) {
modify(x,-val[x]); fix(dfn[x],-val[x]);val[x]=y;
modify(x,val[x]); fix(dfn[x],val[x]);
}else {
printf("%llu\n",query(x,y));
}
}
}