#include <bits/stdc++.h>
#define SIZE 100005
using namespace std;
ifstream f("heavypath.in");
ofstream g("heavypath.out");
int n,m,k,aint[4*SIZE],val[SIZE],tata[SIZE],sz[SIZE],niv[SIZE],head[SIZE],v[SIZE],poz[SIZE];
vector<int>a[SIZE];
void update(int nod,int st,int dr,int index,int newvalue)
{
if(st==dr)aint[nod]=newvalue;
else
{
int mij=(st+dr)/2;
if(index<=mij)update(2*nod,st,mij,index,newvalue);
else update(2*nod+1,mij+1,dr,index,newvalue);
aint[nod]=max(aint[2*nod],aint[2*nod+1]);
}
}
void update(int index,int newvalue)
{
update(1,1,n,index,newvalue);
}
int query(int nod,int st,int dr,int left,int right)
{
if(st==left && dr==right)return aint[nod];
else
{
int mij=(st+dr)/2;
if(right<=mij)return query(2*nod,st,mij,left,right);
else if(left>mij)return query(2*nod+1,mij+1,dr,left,right);
else return max(query(2*nod,st,mij,left,mij),query(2*nod+1,mij+1,dr,mij+1,right));
}
}
int query(int left,int right)
{
return query(1,1,n,left,right);
}
void dfs(int nod)
{
sz[nod]=1;
for(auto u:a[nod])
if(u!=tata[nod])
{
niv[u]=niv[nod]+1;
tata[u]=nod;
dfs(u);
sz[nod]+=sz[u];
}
}
void dfs_greu(int nod)
{
int heavy=0;
v[++k]=nod;
poz[nod]=k;
for(auto u:a[nod])
if(u!=tata[nod] && sz[u]>sz[heavy])heavy=u;
if(!heavy)return;
head[heavy]=head[nod];
dfs_greu(heavy);
for(auto u:a[nod])
if(u!=heavy && u!=tata[nod])dfs_greu(u);
}
void update_heavy(int x,int y)
{
update(poz[x],y);
}
int query_heavy(int x,int y)
{
int sol;
if(head[x]==head[y])
{
if(niv[x]>niv[y])swap(x,y);
sol=query(poz[x],poz[y]);
}
else
{
if(niv[head[x]]<niv[head[y]])swap(x,y);
sol=query(poz[head[x]],poz[x]);
x=tata[head[x]];
sol=max(sol,query_heavy(x,y));
}
return sol;
}
int main()
{
int i,x,y,t;
f>>n>>m;
for(i=1;i<=n;i++)f>>val[i];
for(i=1;i<=n-1;i++)
{
f>>x>>y;
a[x].push_back(y);
a[y].push_back(x);
}
dfs(1);
for(i=1;i<=n;i++)
head[i]=i;
dfs_greu(1);
for(i=1;i<=n;i++)update_heavy(i,val[i]);
for(i=1;i<=m;i++)
{
f>>t>>x>>y;
if(t==0)
{
update_heavy(x,y);
}
else
{
g<<query_heavy(x,y)<<'\n';
}
}
return 0;
}