#include<fstream>
#include<vector>
#define NMAX 100005
#define VEC G[nod][i]
#define son (nod<<1)
#define middle ((left+right)>>1)
using namespace std;
ifstream fin("heavypath.in");
ofstream fout("heavypath.out");
int n,Q,v[NMAX],level[NMAX],k,which[NMAX],what[NMAX],TT_log[NMAX],R[NMAX];
int AINT[4*NMAX],Maxx,start[NMAX],K,first[NMAX],last[NMAX],str[18][NMAX];
vector<int> G[NMAX],decomp[NMAX];
void read()
{
fin>>n>>Q;
for(int i=1;i<=n;i++)
fin>>v[i];
for(int i=1,x,y;i<n;i++)
{
fin>>x>>y;
G[x].push_back(y);
G[y].push_back(x);
}
}
void DFS_split(int nod,int tt,int lant)
{
str[0][nod]=tt;
level[nod]=level[tt]+1;
first[nod]=++K;
if(G[nod].size()==2 && nod!=1)
{
if(!lant)
{
k++;
TT_log[k]=tt;
}
lant=1;
R[k]=max(R[k],nod);
which[nod]=k;
decomp[k].push_back(nod);
}
else
{
if(decomp[k].size()==1)
{
which[decomp[k][0]]=0;
decomp[k].clear();
k--;
}
lant=0;
}
for(size_t i=0;i<G[nod].size();i++)
if(VEC!=tt)
DFS_split(VEC,nod,lant);
last[nod]=K;
}
inline void update(int left,int right,int nod,int val,int poz)
{
if(left==right)
{
AINT[nod]=val;
return;
}
if(poz<=middle)
update(left,middle,son,val,poz);
else
update(middle+1,right,son+1,val,poz);
AINT[nod]=max(AINT[son],AINT[son+1]);
}
void query(int left,int right,int nod,int L,int R)
{
if(left>R || right<L)
return;
if(L<=left && right<=R)
{
Maxx=max(Maxx,AINT[nod]);
return;
}
query(left,middle,son,L,R);
query(middle+1,right,son+1,L,R);
}
void Max(int &A,int &maxim)
{
Maxx=0;
if(which[A])
{
query(1,n,1,start[which[A]],what[A]);
maxim=max(maxim,Maxx);
A=TT_log[which[A]];
}
else
{
maxim=max(maxim,v[A]);
A=str[0][A];
}
}
void group_init()
{
for(int i=1,L=1;i<=k;i++)
{
start[i]=L;
for(size_t j=0;j<decomp[i].size();j++,L++)
{
what[decomp[i][j]]=L;
update(1,n,1,v[decomp[i][j]],L);
}
decomp[i].clear();
}
}
void ancestors()
{
for(int i=1;(1<<i)<=n;i++)
for(int j=1;j<=n;j++)
str[i][j]=str[i-1][str[i-1][j]];
}
void prep()
{
DFS_split(1,0,0);
group_init();
ancestors();
}
void jump(int &x,int &y)
{
int d;
d=level[x]-level[y];
for(int step=17;step>=0;step--)
if(d>=(1<<step))
{
d-=(1<<step);
x=str[step][x];
}
}
int LCA(int x,int y)
{
if(level[x]>level[y])
jump(x,y);
if(level[x]<level[y])
jump(y,x);
if(x==y)
return x;
for(int step=17;step>=0;step--)
if(str[step][x]!=str[step][y])
{
x=str[step][x];
y=str[step][y];
}
return str[0][x];
}
int main()
{
read();
prep();
int cont=0;
for(int op,x,y,lca,maxim;Q;Q--)
{
fin>>op>>x>>y;
if(!op)
{
v[x]=y;
if(which[x])
update(1,n,1,y,what[x]);
continue;
}
cont++;
Maxx=0;
maxim=0;
if(cont==3153)
{
cont++;
cont--;
}
if(x==y)
{
fout<<v[x]<<'\n';
continue;
}
if(first[x]>first[y])
swap(x,y);
if(last[y]<=last[x])
{
if(which[x]==which[y] && which[x])
{
Maxx=0;
query(1,n,1,what[x],what[y]);
fout<<Maxx<<'\n';
continue;
}
if(which[x])
{
Maxx=0;
query(1,n,1,what[x],start[which[x]+1]-1);
maxim=max(maxim,Maxx);
x=R[which[x]];
}
else
maxim=max(maxim,v[x]);
while(y!=x)
{
if(which[y] && R[which[y]]==x)
break;
Max(y,maxim);
}
fout<<maxim<<'\n';
continue;
}
else
{
lca=LCA(x,y);
while(x!=lca)
Max(x,maxim);
while(y!=lca)
Max(y,maxim);
fout<<max(maxim,v[x])<<'\n';
}
}
return 0;
}