#include <fstream>
#include <iostream>
#include <vector>
#include <bitset>
#include <string.h>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <time.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <string>
#include <queue>
#include <deque>
using namespace std;
const char infile[] = "heavypath.in";
const char outfile[] = "heavypath.out";
ifstream fin(infile);
ofstream fout(outfile);
const int MAXN = 100005;
const int oo = 0x3f3f3f3f;
typedef vector<int> Graph[MAXN];
typedef vector<int> :: iterator It;
const inline int min(const int &a, const int &b) { if( a > b ) return b; return a; }
const inline int max(const int &a, const int &b) { if( a < b ) return b; return a; }
const inline void Get_min(int &a, const int b) { if( a > b ) a = b; }
const inline void Get_max(int &a, const int b) { if( a < b ) a = b; }
const int DIM = 10000;
char parse[DIM];
int pos;
Graph G, path, arb;
int V[MAXN], depth[MAXN], heavy[MAXN], N, M;
int numPaths, pathWhere[MAXN], pathPosition[MAXN], pathFather[MAXN];
inline int get() {
int number = 0;
char sgn = '+';
while(!('0' <= parse[pos] && parse[pos] <= '9')) {
sgn = parse[pos];
if(++ pos == DIM) {
fin.getline(parse, DIM, '\0');
pos = 0;
}
}
while('0' <= parse[pos] && parse[pos] <= '9') {
number = number * 10 + parse[pos] - '0';
if(++ pos == DIM) {
fin.getline(parse, DIM, '\0');
pos = 0;
}
}
if(sgn == '-')
number *= -1;
return number;
}
inline void DFs(int Node, int father, int actLevel) {
depth[Node] = actLevel;
heavy[Node] = 1;
int heaviest = -1;
for(It it = G[Node].begin(), fin = G[Node].end(); it != fin ; ++ it) {
if(*it == father)
continue;
DFs(*it, Node, actLevel + 1);
if(heaviest == -1 || heavy[*it] > heavy[heaviest])
heaviest = *it;
}
if(heaviest == -1) {
pathWhere[Node] = ++ numPaths;
pathFather[pathWhere[Node]] = father;
path[pathWhere[Node]].push_back(Node);
return;
}
pathWhere[Node] = pathWhere[heaviest];
pathFather[pathWhere[Node]] = father;
path[pathWhere[Node]].push_back(Node);
}
inline void Build(int Node, int st, int dr, vector <int> &aint, vector <int> PATH) {
if(st == dr) {
aint[Node] = V[PATH[st]];
return;
}
int mid = ((st + dr) >> 1);
Build(Node << 1, st, mid, aint, PATH);
Build((Node << 1) | 1, mid+1, dr, aint, PATH);
aint[Node] = max(aint[Node << 1], aint[(Node << 1) | 1]);
}
inline void Update(int Node, int st, int dr, int pos, vector <int> &aint, vector <int> PATH) {
if(st == dr) {
aint[Node] = V[PATH[st]];
return;
}
int mid = ((st + dr) >> 1);
if(pos <= mid)
Update(Node << 1, st, mid, pos, aint, PATH);
else Update((Node << 1) | 1, mid + 1, dr, pos, aint, PATH);
aint[Node] = max(aint[Node << 1], aint[(Node << 1) | 1]);
}
inline int Query(int Node, int st, int dr, int a, int b, vector <int> aint) {
if(a <= st && dr <= b)
return aint[Node];
int mid = ((st + dr) >> 1);
int actmax = -oo;
if(a <= mid)
actmax = max(actmax, Query(Node << 1, st, mid, a, b, aint));
if(mid < b)
actmax = max(actmax, Query((Node << 1) | 1, mid+1, dr, a, b, aint));
return actmax;
}
inline int QueryHeavyPath(int x, int y) {
if(pathWhere[x] == pathWhere[y]) {
if(pathPosition[x] > pathPosition[y])
swap(x, y);
return Query(1, 0, path[pathWhere[x]].size() - 1, pathPosition[x], pathPosition[y], arb[pathWhere[x]]);
}
if(depth[pathFather[pathWhere[x]]] < depth[pathFather[pathWhere[y]]])
swap(x, y);
int actmax = Query(1, 0, path[pathWhere[x]].size() - 1, 0, pathPosition[x], arb[pathWhere[x]]);
return max(actmax, QueryHeavyPath(pathFather[pathWhere[x]], y));
}
int main() {
N = get();
M = get();
for(int i = 1 ; i <= N ; ++ i)
V[i] = get();
for(int i = 1 ; i != N ; ++ i) {
int x, y;
x = get();
y = get();
G[x].push_back(y);
G[y].push_back(x);
}
DFs(1, 0, 1);
for(int i = 1 ; i <= numPaths ; ++ i) {
reverse(path[i].begin(), path[i].end());
for(int j = 0 ; j < int(path[i].size()) ; ++ j)
pathPosition[path[i][j]] = j;
arb[i].resize(4 * path[i].size() + 5);
Build(1, 0, path[i].size() - 1, arb[i], path[i]);
}
for(int i = 1 ; i <= M ; ++ i) {
int op, x, y, z;
op = get();
x = get();
y = get();
if(op == 0) {
V[x] = y;
Update(1, 0, path[pathWhere[x]].size() - 1, pathPosition[x], arb[pathWhere[x]], path[pathWhere[x]]);
}
if(op == 1) {
fout << QueryHeavyPath(x, y) << '\n';
}
}
fin.close();
fout.close();
return 0;
}