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>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;

class HLDecomposition {
	Graph g;
	vector<int> vid, head, heavy, par, depth, inv;
	int dfs(int curr, int prev) {
		par[curr] = prev;
		int sub = 1, max_sub = 0;
		for (auto next : g[curr]) if (next != prev) {
			depth[next] = depth[curr] + 1;
			int sub_next = dfs(next, curr);
			sub += sub_next;
			if (max_sub < sub_next) max_sub = sub_next, heavy[curr] = next;
		}
		return sub;
	}
	void bfs() {
		int k = 0;
		queue<int> q; q.push(0);
		while (!q.empty()) {
			int h = q.front(); q.pop();
			for (int i = h; i != -1; i = heavy[i]) {
				vid[i] = k++;
				inv[vid[i]] = i;
				head[i] = h;
				for (auto j : g[i]) if (j != par[i] && j != heavy[i]) q.push(j);
			}
		}
	}
public:
	HLDecomposition(int n)
		: g(n), vid(n, -1), head(n), heavy(n, -1), par(n), depth(n), inv(n) {}
	void add(int u, int v) {
		g[u].push_back(v);
		g[v].push_back(u);
	}
	void build() {
		dfs(0, -1);
		bfs();
	}
	void for_each(int u, int v, function<void(int, int)> f) {
		if (vid[u] > vid[v]) swap(u, v);
		f(max(vid[head[v]], vid[u]), vid[v]);
		if (head[u] != head[v]) for_each(u, par[head[v]], f);
	}
	void for_each_directed(int u, int v, function<void(int, int, int)> f) {
		if (vid[u] > vid[v]) {
			f(max(vid[head[u]], vid[v]), vid[u], 1);
			if (head[u] != head[v]) for_each_directed(par[head[u]], v, f);
		}
		else {
			f(max(vid[head[v]], vid[u]), vid[v], 0);
			if (head[u] != head[v]) for_each_directed(u, par[head[v]], f);
		}
	}
};


struct node {
	bool flag, id;
	ll l, r, all, sum, cnt, lazy;
	node(ll val) : flag(false), id(false), l(val), r(val), all(val), sum(val), cnt(1), lazy(0) {}
	node(ll l, ll r, ll all, ll sum, ll cnt) : flag(false), id(false), l(l), r(r), all(all), sum(sum), cnt(cnt), lazy(0) {}
	node() : flag(false), id(true), cnt(0), lazy(0) {}
};

node merge(const node& l, const node& r) {
	if (l.id) return r;
	if (r.id) return l;
	ll resl = max(l.l, l.sum + r.l);
	ll resr = max(l.r + r.sum, r.r);
	ll ressum = l.sum + r.sum;
	ll rescen = max(l.all, max(r.all, max(l.r + r.l, max(l.r, r.l))));
	return node(resl, resr, max(rescen, max(resl, resr)), ressum, l.cnt + r.cnt);
}

node real(const node& n) {
	if (!(n.flag) || n.id) return n;
	ll sum = n.lazy * n.cnt;
	return n.lazy >= 0 ? node(sum, sum, sum, sum, n.cnt) : node(n.lazy, n.lazy, n.lazy, sum, n.cnt);
}

class LazySegmentTree {
	const int n;
	vector<node> data;
	int size(int n) {
		int res = 1;
		while (res < n) res <<= 1;
		return res;
	}
	void suc(int l, int r, int node, int lb, int ub, ll val) {
		if (ub <= l || r <= lb) return;
		if (l <= lb && ub <= r) {
			data[node].flag = true;
			data[node].id = false;
			data[node].lazy = val;
			return;
		}
		int left = node * 2, right = node * 2 + 1;
		if (data[node].flag) {
			data[left].flag = data[right].flag = true;
			data[left].id = data[right].id = false;
			data[left].lazy = data[right].lazy = data[node].lazy;
			data[node] = real(data[node]);
			data[node].flag = false;
		}
		suc(l, r, left, lb, (lb + ub) / 2, val);
		suc(l, r, right, (lb + ub) / 2, ub, val);
		data[node] = merge(real(data[left]), real(data[right]));
	}
	node sub(int l, int r, int node, int lb, int ub) {
		if (ub <= l || r <= lb) return ::node();
		if (l <= lb && ub <= r) {
			return real(data[node]);
		}
		int left = node * 2, right = node * 2 + 1;
		if (data[node].flag) {
			data[left].flag = data[right].flag = true;
			data[left].id = data[right].id = false;
			data[left].lazy = data[right].lazy = data[node].lazy;
			data[node] = real(data[node]);
			data[node].flag = false;
		}
		return merge(sub(l, r, left, lb, (lb + ub) / 2), sub(l, r, right, (lb + ub) / 2, ub));
	}
public:
	LazySegmentTree(int n_) :
		n(size(n_)), data(n * 2, node()) {}
	void Init() {
		for (int i = n - 1; i > 0; i--) {
			data[i] = merge(data[i * 2], data[i * 2 + 1]);
		}
	}
	void update(int p, ll val) {
		data[n + p] = node(val);
	}
	void update(int l, int r, ll val) {
		suc(l, r + 1, 1, 0, n, val);
	}
	node find(int l, int r) {
		return sub(l, r + 1, 1, 0, n);
	}
};

int main()
{
	cin.sync_with_stdio(false);
	cin.tie(0);
	ll n, q, t, a, b, c;
	cin >> n >> q;
	vector<ll> w(n);
	for (int i = 0; i < n; i++) {
		cin >> w[i];
	}
	HLDecomposition hl(n);
	for (int i = 0, u, v; i < n - 1; i++) {
		cin >> u >> v; u--; v--;
		hl.add(u, v);
	}
	hl.build();
	LazySegmentTree lst(n);
	for (int i = 0; i < n; i++) {
		hl.for_each(i, i, [&](int l, int r) {
			lst.update(l, w[i]);
		});
	}
	lst.Init();
	while (q--) {
		cin >> t >> a >> b >> c; a--; b--;
		if (t == 1) {
			hl.for_each(a, b, [&](int l, int r) {
				lst.update(l, r, c);
			});
		}
		else {
			node left, right;
			hl.for_each_directed(a, b, [&](int l, int r, int b) {
				if (b) {
					auto tmp = lst.find(l, r); swap(tmp.l, tmp.r);
					left = merge(left, tmp);
				}
				else {
					right = merge(lst.find(l, r), right);
				}
			});
			node res = merge(left, right);
			printf("%lld\n", res.all);
		}
	}
	return 0;
}