#include<fstream>
#include<vector>
#include<cstdlib>
#include<ctime>
using namespace std;
ifstream in("heavypath.in");
ofstream out("heavypath.out");
const int Nmax = 100001;
vector<int> G[Nmax],Comp[Nmax];
int h[Nmax],L[Nmax];
int chfat[Nmax],St[Nmax];
int pof[Nmax],pos[Nmax];
int v[Nmax],A[4*Nmax];
int N,M,K;
void upd(int i,int st,int dr,int &w,int &val){
if(st>=dr) A[i]=val;
else{
int mij=(st+dr)/2;
if(w<=mij) upd(2*i,st,mij,w,val);
else upd(2*i+1,mij+1,dr,w,val);
A[i]=max(A[2*i],A[2*i+1]);
}
}
int query(int i,int st,int dr,int a,int b){
if(a<=st && dr<=b) return A[i];
int mij=(st+dr)/2;
if(b<=mij) return query(2*i,st,mij,a,b);
if(a>mij) return query(2*i+1,mij+1,dr,a,b);
int r1=query(2*i,st,mij,a,mij);
int r2=query(2*i+1,mij+1,dr,mij+1,b);
return max(r1,r2);
}
void dfsh(int x,int l){
L[x]=l,h[x]=1;
for(vector<int>::iterator it=G[x].begin();it!=G[x].end();++it)
if(!L[*it]) dfsh(*it,l+1),h[x]+=h[*it];
}
void dfss(int x,int k){
Comp[k].push_back(x);
pof[x]=k,pos[x]=Comp[k].size();
int ch=0;
for(vector<int>::iterator it=G[x].begin();it!=G[x].end();++it) if(h[*it]<h[x])
if(ch==0 || h[ch]<h[*it]) ch=*it;
for(vector<int>::iterator it=G[x].begin();it!=G[x].end();++it) if(h[*it]<h[x]){
if(*it==ch) dfss(*it,k);
else chfat[++K]=x,dfss(*it,K);
}
}
int rasp(int x,int y){
int s=0;
while(pof[x]!=pof[y]){
if(L[chfat[pof[x]]]<L[chfat[pof[y]]]) swap(x,y);
s=max(s,query(1,1,N,St[pof[x]],St[pof[x]]+pos[x]-1));
x=chfat[pof[x]];
}
if(L[x]>L[y]) swap(x,y);
s=max(s,query(1,1,N,St[pof[x]]+pos[x]-1,St[pof[y]]+pos[y]-1));
return s;
}
int main(){
srand(time(0));
in>>N>>M;
for(int i=1;i<=N;i++) in>>v[i];
int t=0,x,y;
for(int i=1;i<N;i++){
in>>x>>y;
G[x].push_back(y);
G[y].push_back(x);
}
int root=rand()%N+1;
dfsh(root,1);
dfss(root,++K);
for(int i=1;i<=K;i++){
St[i]=t+1;
for(vector<int>::iterator it=Comp[i].begin();it!=Comp[i].end();++it) upd(1,1,N,++t,v[*it]);
}
for(int i=1;i<=M;i++){
in>>t>>x>>y;
if(t==0) x=St[pof[x]]+pos[x]-1,upd(1,1,N,x,y);
if(t==1) out<<rasp(x,y)<<'\n';
}
return 0;
}