#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
ifstream fin("heavypath.in");
ofstream fout("heavypath.out");
const int maxN = 100005;
int n, q, v[maxN], sz[maxN], depth[maxN], lant[maxN], poz[maxN], cap[maxN], currPoz, currLant, p[maxN];
vector <int> G[maxN];
struct SegTree {
int sz;
vector <int> aint;
void update(int poz, int val, int nod, int st, int dr) {
if (st == dr) {
aint[nod] = val;
return;
}
int med = (st + dr) / 2;
if (poz <= med) {
update(poz, val, 2 * nod, st, med);
}
else
update(poz, val, 2 * nod + 1, med + 1, dr);
aint[nod] = max(aint[2 * nod], aint[2 * nod + 1]);
}
int query(int qst, int qdr, int nod, int st, int dr) {
if (st == dr) {
return aint[nod];
}
int med = (st + dr) / 2, maxi = 0;
if (qst <= med) {
maxi = max(maxi, query(qst, qdr, 2 * nod, st, med));
}
if (med < qdr) {
maxi = max(maxi, query(qst, qdr, 2 * nod + 1, med + 1, dr));
}
return maxi;
}
void init(int N) {
sz = N;
aint.resize(4 * sz + 1);
}
}T;
void dfs(int nod, int tata) {
p[nod] = tata;
sz[nod] = 1;
depth[nod] = depth[tata] + 1;
for (int vecin : G[nod]) {
if (vecin == tata) {
continue;
}
dfs(vecin, nod);
sz[nod] += sz[vecin];
}
}
void dfsHeavy(int nod, int tata, bool heavy) {
if (heavy) {
lant[nod] = lant[tata];
}
else {
lant[nod] = ++currLant;
cap[currLant] = nod;
}
poz[nod] = ++currPoz;
int heavySon = 0;
for (int vecin : G[nod]) {
if (vecin == tata) {
continue;
}
if (sz[vecin] > sz[heavySon])
heavySon = vecin;
}
if (heavySon)
dfsHeavy(heavySon, nod, 1);
for (int vecin : G[nod]) {
if (vecin == tata) {
continue;
}
if (vecin == heavySon) {
continue;
}
dfsHeavy(vecin, nod, 0);
}
}
int calc(int x, int y) {
if (lant[x] == lant[y]) {
if (poz[x] > poz[y])
swap(x, y);
return T.query(poz[x], poz[y], 1, 1, n);
}
if (depth[cap[lant[x]]] < depth[cap[lant[y]]])
swap(x, y);
return max(T.query(poz[cap[lant[x]]], poz[x], 1, 1, n), calc(p[cap[lant[x]]], y));
}
int main() {
fin >> n >> q;
for (int i = 1; i <= n; i++) {
fin >> v[i];
}
for (int i = 1; i < n; i++) {
int x, y;
fin >> x >> y;
G[x].push_back(y);
G[y].push_back(x);
}
dfs(1, 0);
dfsHeavy(1, 0, 1);
T.init(n);
for (int i = 1; i <= n; i++) {
T.update(poz[i], v[i], 1, 1, n);
}
for (int i = 1; i <= q; i++) {
int op;
fin >> op;
if (op == 0) {
int nod, val;
fin >> nod >> val;
v[nod] = val;
T.update(poz[nod], v[nod], 1, 1, n);
}
if (op == 1) {
int x, y;
fin >> x >> y;
fout << calc(x, y) << '\n';
}
}
return 0;
}