Problem: Given a tree with n (1 ≤ n ≤ 200,000) nodes and a list of q (1 ≤ q ≤ 100,000) queries, process the queries in order and output a value for each output query. The given tree is connected and each node on the tree has a weight wi (-10,000 ≤ wi ≤ 10,000).

Each query consists of a number ti (ti = 1, 2), which indicates the type of the query , and three numbers ai, bi and ci (1 ≤ ai, bi ≤ n, -10,000 ≤ ci ≤ 10,000). Depending on the query type, process one of the followings:

* (ti = 1: modification query) Change the weights of all nodes on the shortest path between ai and bi (both inclusive) to ci.

* (ti = 2: output query) First, create a list of weights on the shortest path between ai and bi (both inclusive) in order. After that, output the maximum sum of a non-empty continuous subsequence of the weights on the list. ci is ignored for output queries.



Input

The first line contains two integers n and q. On the second line, there are n integers which indicate w1, w2, ... , wn.

Each of the following n - 1 lines consists of two integers si and ei (1 ≤ si, ei ≤ n), which means that there is an edge between si and ei.

Finally the following q lines give the list of queries, each of which contains four integers in the format described above. Queries must be processed one by one from top to bottom.

Output

For each output query, output the maximum sum in one line.

Examples

Input

3 4
1 2 3
1 2
2 3
2 1 3 0
1 2 2 -4
2 1 3 0
2 2 2 0


Output

6
3
-4


Input

7 5
-8 5 5 5 5 5 5
1 2
2 3
1 4
4 5
1 6
6 7
2 3 7 0
2 5 2 0
2 4 3 0
1 1 1 -1
2 3 7 0


Output

12
10
10
19


Input

21 30
10 0 -10 -8 5 -5 -4 -3 1 -2 8 -1 -7 2 7 6 -9 -6 3 4 9
10 3
3 2
3 12
12 4
4 13
4 9
10 21
21 1
1 11
11 14
1 15
10 6
6 17
6 16
6 5
5 18
5 19
10 7
10 8
8 20
1 1 21 -10
1 3 19 10
2 1 13 0
1 4 18 8
1 5 17 -5
2 16 7 0
1 6 16 5
1 7 15 4
2 4 20 0
1 8 14 3
1 9 13 -1
2 9 18 0
1 10 12 2
1 11 11 -8
2 21 15 0
1 12 10 1
1 13 9 7
2 6 14 0
1 14 8 -2
1 15 7 -7
2 10 2 0
1 16 6 -6
1 17 5 9
2 12 17 0
1 18 4 6
1 19 3 -3
2 11 8 0
1 20 2 -4
1 21 1 -9
2 5 19 0


Output

20
9
29
27
10
12
1
18
-2
-3

Solution (in CPP):

Solution:
#include<bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9 + 100000;
const double INF = 1e12, EPS = 1e-9;

template<class T>struct SegTree{
	T *ans, *sum, *left, *right, *lazy;
	
	int n;
	SegTree(int size = 1000000){
		for(n = 1; n < size; n *= 2);
		ans = new T[2 * n - 1];
		sum = new T[2 * n - 1];
		left = new T[2 * n - 1];
		right = new T[2 * n - 1];
		lazy = new T[2 * n - 1];
		
		rep(i, 2 * n - 1) sum[i] = ans[i] = right[i] = left[i] = 0, lazy[i] = inf;
	}
	~SegTree(){
		delete ans; delete sum;
		delete left; delete right;
		delete lazy;
	}
	
	inline void fix(int i){
		int l = i * 2 + 1, r = i * 2 + 2;
		ans[i] = max(max(ans[l], ans[r]), left[r] + right[l]);
		sum[i] = sum[l] + sum[r];
		left[i] = max(sum[l] + left[r], left[l]);
		right[i] = max(sum[r] + right[l], right[r]);
	}
	inline void lazyfix(int k, int l, int r){
		if(lazy[k] == inf) return;
		update(l, (l + r) / 2, lazy[k], k * 2 + 1, l, (l + r) / 2);
		update((l + r) / 2, r, lazy[k], k * 2 + 2, (l + r) / 2, r);
		lazy[k] = inf;
	}
	
	void init(){
		for(int i = n - 2; i >= 0; i--) fix(i);
	}
	inline void update(int a, int b, T x){
		update(a, b, x, 0, 0, n);
	}
	
	inline void update(int a, int b, T x, int k, int l, int r){
		
		if(b <= l || a >= r) return;
		if(a <= l && r <= b){
			lazy[k] = x;
			left[k] = right[k] = ans[k] = x >= 0 ? (r - l) * x : x;
			sum[k] = (r - l) * x;
			return;
		}
		lazyfix(k, l, r);
		
		int lch = k * 2 + 1, rch = k * 2 + 2;
		update(a, b, x, lch, l, (l + r) / 2);
		update(a, b, x, rch, (l + r) / 2, r);
		fix(k);
	}
	
	#define LEFT a, b, k * 2 + 1, l, (l + r) / 2
	#define RIGHT a, b, k * 2 + 2, (l + r) / 2, r
	
	inline T query(int a, int b, int k, int l, int r){
		if(r <= a || b <= l) return -inf;
		if(a <= l && r <= b) return ans[k];
		lazyfix(k, l, r);
		
		int vl = query(LEFT);
		int vr = query(RIGHT);
		int vll = queryRight(LEFT);
		int vrr = queryLeft (RIGHT);
		return max(max(vl, vr), vll + vrr);
	}
	inline T querySum(int a, int b, int k, int l, int r){
		if(r <= a || b <= l) return 0;
		if(a <= l && r <= b) return sum[k];
		lazyfix(k, l, r);
		
		int vl = querySum(LEFT);
		int vr = querySum(RIGHT);
		return vl + vr;
	}
	inline T queryRight(int a, int b, int k, int l, int r){
		if(r <= a || b <= l) return -inf;
		if(a <= l && r <= b) return right[k];
		lazyfix(k, l, r);
		
		int R = queryRight(RIGHT);
		int rsum = querySum(RIGHT);
		int lr = queryRight(LEFT);
		return max(R, rsum + lr);
	}
	inline T queryLeft(int a, int b, int k, int l, int r){
		if(r <= a || b <= l) return -inf;
		if(a <= l && r <= b) return left[k];
		lazyfix(k, l, r);
		
		int L = queryLeft(LEFT);
		int lsum = querySum(LEFT);
		int rl = queryLeft(RIGHT);
		return max(L, lsum + rl);
	}
	#undef LEFT
	#undef RIGHT
};

const int MX = 200000;
const int MX_L=18;

SegTree<int> *st[MX];
int st_root[MX];
int st_sz;

int n, q;
int w[MX];
int sz[MX];
int parent[MX_L][MX];
int depth[MX];
int which[MX];

vector<vi> e;

void size_rec(int, int);
void heavy_light_rec(int, int, int);
void segtest();

void fix(int a, int b, int c){
	while(1){
		if(which[a] < 0){
			w[a] = c;
			if(a == b) break;
			a = parent[0][a];
		}
		else{
			int v = st_root[which[a]];
			int base = depth[v];
			
			if(depth[v] <= depth[b]) v = b;
			int da = depth[a] - base;
			int dv = depth[v] - base;
			
			st[which[a]]->update(dv, da + 1, c);
			if(v == b) break;
			a = parent[0][v];
		}
	}
}
pi calc(int a, int b){
	int res = -inf, resleft = -inf;
	
	while(1){
		if(which[a] < 0){
			res = max(res, max(w[a], resleft > -inf ? w[a] + resleft : -inf));
			resleft = max(w[a], resleft > -inf ? w[a] + resleft : -inf);
			if(a == b) break;
			a = parent[0][a];
		}
		else{
			int v = st_root[which[a]];
			int base = depth[v];
			
			if(depth[v] <= depth[b]) v = b;
			int da = depth[a] - base;
			int dv = depth[v] - base;
			
			int m = st[which[a]]->n;
			int Q = st[which[a]]->query(dv, da + 1, 0, 0, m);
			int L = st[which[a]]->queryLeft(dv, da + 1, 0, 0, m);
			int R = st[which[a]]->queryRight(dv, da + 1, 0, 0, m);
			int S = st[which[a]]->querySum(dv, da + 1, 0, 0, m);
			
			res = max(res, max(Q, resleft > -inf ? R + resleft : -inf));
			resleft = max(resleft > -inf ? S + resleft : -inf, L);
			if(v == b) break;
			a = parent[0][v];
		}
	}
	
	return mp(res, resleft);
}

void run(){
	scanf("%d%d", &n, &q);
	rep(i, n) scanf("%d", w + i);
	
	e.resize(n);
	rep(i, n - 1){
		int a, b; scanf("%d%d", &a, &b);
		a--; b--;
		e[a].pb(b); e[b].pb(a);
	}
	memset(which, -1, sizeof(which));
	size_rec(0, 0);
	heavy_light_rec(0, 0, -1);
	
	rep(i, MX_L - 1) rep(j, n) parent[i + 1][j] = parent[i][parent[i][j]];
	
	
	while(q--){
		int t, aa, bb, c, v;
		scanf("%d%d%d%d", &t, &aa, &bb, &c);
		aa--; bb--;
		if(depth[aa] > depth[bb]) swap(aa, bb);
		
		int a = aa, b = bb;
		int d = depth[b] - depth[a];
		
		rep(i, MX_L) if(d & 1 << i) b = parent[i][b];
		if(a == b) v = a;
		else{
			for(int i = MX_L - 1; i >= 0; i--) if(parent[i][a] != parent[i][b]){
				a = parent[i][a];
				b = parent[i][b];
			}
			v = parent[0][a];
		}
		
		if(t == 1){
			fix(aa, v, c); fix(bb, v, c);
		}
		else{
			if(v == aa){
				printf("%d\n", calc(bb, aa).first);
			}
			else{
				pi x = calc(aa, a), y = calc(bb, v);
				int ans = max(max(x.first, y.first), x.second + y.second);
				
				printf("%d\n", ans);
			}
		}
	}
}

void size_rec(int c, int p){
	sz[c] = 1;
	depth[c] = c == p ? 0 : depth[p] + 1;
	parent[0][c] = p;
	rep(i, e[c].size()) if(e[c][i] != p){
		size_rec(e[c][i], c);
		sz[c] += sz[e[c][i]];
	}
}
void heavy_light_rec(int c, int p, int root){
	
	bool found = 0;
	
	rep(i, e[c].size()){
		int to = e[c][i];
		if(to == p) continue;
		
		if(2 * sz[to] >= sz[c]){
			heavy_light_rec(to, c, root < 0 ? c : root);
			found = 1;
		}
		else heavy_light_rec(to, c, -1);
	}
	if(!found && root >= 0){
		int size = depth[c] - depth[root] + 1;
		SegTree<int> *t = st[st_sz] = new SegTree<int>(size);
		st_root[st_sz] = root;
		
		for(int v = c, k = size - 1 + t->n - 1; ; v = parent[0][v], k--){
			which[v] = st_sz;
			t->left[k] = t->right[k] = t->ans[k] = w[v];
			t->sum[k] = w[v];
			if(v == root) break;
		}
		t->init();
		st_sz++;
	}
}
long long esp_org, esp_new;
int main(){
	const int size = 128*1024*1024;
	void *p = malloc(size);
	esp_new = (long long)p + size - 1;
	
	
	__asm__("mov %%rsp, %0" : "=r"(esp_org) : : );
	__asm__("mov %0, %%rsp" : : "r"(esp_new) : );
	
	run();
	
	__asm__("mov %0, %%rsp" : : "r"(esp_org) : );
	free(p);
	return 0;
}