#include <bits/stdc++.h>
using namespace std;
const int NMAX = 1e5;
int subsize[NMAX + 1];
int father[NMAX + 1];
int depth[NMAX + 1];
int viz[NMAX + 1];
int heavy_position[NMAX + 1];
int heavy_paths[NMAX + 1];
int aint[NMAX * 4];
int heavy_root[NMAX + 1];
int v[NMAX + 1];
vector <int> edges[NMAX + 1];
int n;
void update( int st, int dr, int poz, int val, int i ) {
if ( st == dr ) {
aint[i] = val;
return;
}
int mij = ( st + dr ) / 2;
if ( poz <= mij )
update( st, mij, poz, val, i * 2 + 1 );
else
update( mij + 1, dr, poz, val, i * 2 + 2 );
aint[i] = max( aint[i * 2 + 1], aint[i * 2 + 2] );
}
int query( int st, int dr, int a, int b, int i ) {
if ( a == st && b == dr ) {
return aint[i];
}
int mij = ( st + dr ) / 2;
if ( b <= mij ) {
return query( st, mij, a, b, i * 2 + 1 );
}
if ( a > mij ) {
return query( mij + 1, dr, a, b, i * 2 + 2 );
}
return max( query( st, mij, a, mij, i * 2 + 1 ),
query( mij + 1, dr, mij + 1, b, i * 2 + 2 ) );
}
int init_subsize( int node, int previous, int dpth ) {
int ss = 1;
viz[node] = 1;
father[node] = previous;
depth[node] = dpth;
for ( auto it : edges[node] ) {
if ( !viz[it] ) {
ss += init_subsize( it, node, dpth + 1 );
}
}
viz[node] = 0;
subsize[node] = ss;
return ss;
}
int pos;
void init_heavy( int node, int root ) {
int heavy_child = 0;
viz[node] = 1;
heavy_position[node] = pos;
heavy_paths[pos] = node;
update( 1, n, pos, v[node], 0 );
heavy_root[node] = root;
pos ++;
for ( auto it : edges[node] ) {
if ( !viz[it] && subsize[it] > subsize[heavy_child] )
heavy_child = it;
}
if ( heavy_child != 0 )
init_heavy( heavy_child, root );
}
class InParser {
private:
FILE *fin;
char *buff;
int sp;
char read_ch() {
++sp;
if (sp == 4096) {
sp = 0;
fread(buff, 1, 4096, fin);
}
return buff[sp];
}
public:
InParser(const char* nume) {
fin = fopen(nume, "r");
buff = new char[4096]();
sp = 4095;
}
InParser& operator >> (int &n) {
char c;
while (!isdigit(c = read_ch()) && c != '-');
int sgn = 1;
if (c == '-') {
n = 0;
sgn = -1;
} else {
n = c - '0';
}
while (isdigit(c = read_ch())) {
n = 10 * n + c - '0';
}
n *= sgn;
return *this;
}
InParser& operator >> (long long &n) {
char c;
n = 0;
while (!isdigit(c = read_ch()) && c != '-');
long long sgn = 1;
if (c == '-') {
n = 0;
sgn = -1;
} else {
n = c - '0';
}
while (isdigit(c = read_ch())) {
n = 10 * n + c - '0';
}
n *= sgn;
return *this;
}
};
class OutParser {
private:
FILE *fout;
char *buff;
int sp;
void write_ch(char ch) {
if (sp == 50000) {
fwrite(buff, 1, 50000, fout);
sp = 0;
buff[sp++] = ch;
} else {
buff[sp++] = ch;
}
}
public:
OutParser(const char* name) {
fout = fopen(name, "w");
buff = new char[50000]();
sp = 0;
}
~OutParser() {
fwrite(buff, 1, sp, fout);
fclose(fout);
}
OutParser& operator << (int vu32) {
if (vu32 <= 9) {
write_ch(vu32 + '0');
} else {
(*this) << (vu32 / 10);
write_ch(vu32 % 10 + '0');
}
return *this;
}
OutParser& operator << (long long vu64) {
if (vu64 <= 9) {
write_ch(vu64 + '0');
} else {
(*this) << (vu64 / 10);
write_ch(vu64 % 10 + '0');
}
return *this;
}
OutParser& operator << (char ch) {
write_ch(ch);
return *this;
}
OutParser& operator << (const char *ch) {
while (*ch) {
write_ch(*ch);
++ch;
}
return *this;
}
};
int main() {
InParser fin( "heavypath.in" );
OutParser fout( "heavypath.out" );
int i, a, b, q, t, ans;
fin >> n >> q;
for ( i = 1; i <= n; i ++ ) {
fin >> v[i];
}
for ( i = 0; i < n - 1; i ++ ) {
fin >> a >> b;
edges[a].push_back( b );
edges[b].push_back( a );
}
init_subsize( 1, -1, 0 );
pos = 1;
for ( i = 1; i <= n; i ++ ) {
if ( !viz[i] ) {
init_heavy( i, i );
}
}
for ( i = 0; i < q; i ++ ) {
fin >> t >> a >> b;
if ( t == 0 ) {
update( 1, n, heavy_position[a], b, 0 );
} else {
ans = 0;
while ( heavy_root[a] != heavy_root[b] ) {
if ( depth[heavy_root[a]] > depth[heavy_root[b]] ) {
ans = max( ans, query( 1, n, heavy_position[heavy_root[a]], heavy_position[a], 0 ) );
a = father[heavy_root[a]];
} else {
ans = max( ans, query( 1, n, heavy_position[heavy_root[b]], heavy_position[b], 0 ) );
b = father[heavy_root[b]];
}
}
int x, y;
x = min( heavy_position[a], heavy_position[b] );
y = max( heavy_position[a], heavy_position[b] );
ans = max( ans, query( 1, n, x, y, 0 ) );
fout << ans << '\n';
}
}
return 0;
}