//LCA+排序
//用的是倍增的在线算法。。。。
#include <iostream>
#include<stdio.h>
#include<string.h>
#include<string>
#include<algorithm>
using namespace std;
const int maxn=80000+10;
int val[maxn];
int temp[maxn];
struct node
{
int from;
int to;
int next;
}edge[2*maxn];
int deep[maxn];
int head[maxn];
int pos[maxn][32];
int tot;
inline void addEdge(int from,int to)
{
edge[tot].from=from;
edge[tot].to=to;
edge[tot].next=head[from];
head[from]=tot++;
}
inline void dfs(int u)
{
for(int i=head[u];i!=-1;i=edge[i].next)
{
if(!deep[edge[i].to])
{
deep[edge[i].to]=deep[u]+1;
pos[edge[i].to][0]=u;
dfs(edge[i].to);
}
}
}
int n,q;
inline void init()
{
for(int i=1;(1<<i)<=n;i++)
{
for(int j=1;j<=n;j++)
{
if(pos[j][i-1]!=-1)
{
pos[j][i]=pos[pos[j][i-1]][i-1];
}
}
}
}
inline void lca(int k,int a,int b)
{
//cout<<val[a]<<" "<<val[b]<<endl;
int sum=0,i;
temp[sum++]=val[a];
temp[sum++]=val[b];
if(deep[a]<deep[b])
{
swap(a,b);
}
for(i=0;(1<<i)<=deep[a];i++);
i--;
while(deep[a]>deep[b])
{
a=pos[a][0];
temp[sum++]=val[a];
//cout<<"val[a]:"<<val[a]<<endl;
}
if(a==b)
sum-=1;
if(a!=b)
{
while(a!=b)
{
a=pos[a][0];
temp[sum++]=val[a];
b=pos[b][0];
temp[sum++]=val[b];
}
// cout<<a<<" "<<b<<endl;
sum-=1;
//cout<<"zu xian:"<<pos[a][0]<<endl;
}
sort(temp,temp+sum);
//cout<<temp[0]<<temp[1]<<temp[2]<<endl;
// cout<<"k:sum+1"<<k<<" "<<sum+1<<endl;
if(k>sum)
printf("invalid request!\n");
else
printf("%d\n",temp[sum-k]);
}
int main()
{
while(scanf("%d%d",&n,&q)!=EOF)
{
memset(head,-1,sizeof(head));
memset(deep,0,sizeof(deep));
memset(pos,-1,sizeof(pos));
for(int i=1;i<=n;i++)
{
scanf("%d",&val[i]);
}
for(int i=1;i<=n-1;i++)
{
int a,b;
scanf("%d%d",&a,&b);
addEdge(a,b);
addEdge(b,a);
}
dfs(1);
init();
for(int i=1;i<=q;i++)
{
int k,a,b;
scanf("%d%d%d",&k,&a,&b);
if(k==0)
val[a]=b;
else
lca(k,a,b);
}
}
return 0;
}