#include <bits/stdc++.h>
using namespace std;
struct LinkCut {
struct Node {
int p = 0, c[2] = {0, 0}, pp = 0;
bool flip = 0;
int val = 0, dp = 0;
};
vector<Node> T;
LinkCut(int n) : T(n + 1) {}
// SPLAY TREE OPERATIONS START
int dir(int x, int y) { return T[x].c[1] == y; }
void set(int x, int d, int y) {
if (x) {
int& oy = T[x].c[d];
if (T[oy].p == x) T[oy].p = 0;
oy = y; pull(x);
}
if (y) T[y].p = x;
}
void pull(int x) {
if (!x) return;
int &l = T[x].c[0], &r = T[x].c[1];
T[x].dp = max({T[x].val, T[l].dp, T[r].dp});
}
void push(int x) {
if (!x || !T[x].flip) return;
int &l = T[x].c[0], &r = T[x].c[1];
swap(l, r); T[l].flip ^= 1; T[r].flip ^= 1;
T[x].flip = 0;
}
void rotate(int x, int d) {
int y = T[x].p, z = T[y].p, w = T[x].c[d];
swap(T[x].pp, T[y].pp);
set(z, dir(z, y), x);
set(x, d, y);
set(y, !d, w);
}
void splay(int x) {
for (push(x); T[x].p;) {
int y = T[x].p, z = T[y].p;
push(z); push(y); push(x);
int dx = dir(y, x), dy = dir(z, y);
if (!z) {
rotate(x, !dx);
}
else if (dx == dy)
rotate(y, !dx), rotate(x, !dx);
else
rotate(x, dy), rotate(x, dx);
}
}
// SPLAY TREE OPERATIONS END
void Link(int u, int v) {
// cerr << "Link: " << u << " " << v << endl;
MakeRoot(v);
T[v].pp = u;
}
void dump2() {
for (int i = 1; i < (int)T.size(); ++i) {
cerr << i << ": " << T[i].c[0] << " " << T[i].c[1] << " "
<< T[i].p << " " << T[i].pp << endl;
}
}
/// Move u to root of represented tree.
void MakeRoot(int u) {
// cerr << "MakeRoot: " << u << endl;
Access(u);
assert(T[u].p == 0);
// cerr << "REVERSING: "; dump(T[u].c[0]); cerr << endl;
T[T[u].c[0]].flip ^= 1;
T[T[u].c[0]].pp = u;
set(u, 0, 0);
// cerr << "----------" << endl;
}
void Access(int _u) {
// cerr << "Access: " << _u << endl;
for (int v = 0, u = _u; u; u = T[v = u].pp) {
// cerr << "relinking: " << u << " to " << v << endl;
splay(u); splay(v);
// dump(u); cerr << " | "; dump(v); cerr << endl;
if (T[u].c[1])
T[T[u].c[1]].pp = u;
T[v].pp = 0;
set(u, 1, v);
}
splay(_u);
// Dump();
// cerr << "------------" << endl;
}
void Update(int u, int val) {
// cerr << "Update: " << u << " " << val << endl;
splay(u);
T[u].val = val;
pull(u);
// Dump();
}
int Query(int u, int v) {
// cerr << "Query: " << u << " " << v << endl;
MakeRoot(u);
// cerr << "MADE ROOT IN " << u << endl;
// Dump();
Access(v);
// cerr << "ACCESSED " << v << endl;
// Dump();
// splay(v);
// cerr << "SPLAYED " << v << endl;
// Dump();
return T[v].dp;
}
// void Dump() {
// for (int i = 1; i < (int)T.size(); ++i) {
// if (T[i].p) continue;
// cerr << "(" << i << "): "; dump(i);
// cerr << " --> " << T[i].pp << endl;
// }
// }
void dump(int x) {
if (!x) return;
if (T[x].p) assert(!T[x].pp);
push(x);
dump(T[x].c[0]);
cerr << x << " ";
dump(T[x].c[1]);
}
void Dump() {
for (int i = 1; i < (int)T.size(); ++i) {
if (T[i].p) continue;
cerr << T[i].pp << " <-- ";
dump(i);
cerr << endl;
}
cerr << endl;
}
};
int main() {
ifstream cin("heavypath.in");
ofstream cout("heavypath.out");
int n, m; cin >> n >> m;
LinkCut lc(n);
for (int i = 1; i <= n; ++i) {
cin >> lc.T[i].val;
}
for (int i = 1; i < n; ++i) {
int a, b; cin >> a >> b;
lc.Link(a, b);
}
// lc.Dump();
for (int i = 0; i < m; ++i) {
// lc.Dump();
// cerr << endl;
int t, a, b; cin >> t >> a >> b;
if (t == 0) lc.Update(a, b);
else cout << lc.Query(a, b) << '\n';
}
return 0;
}