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;

struct RMS {
	using ll = long long;
	static const ll INF = 1e17;
	struct type {
		ll left, right, all, sum;
		type() : left(-INF), right(-INF), all(-INF), sum(0) {}
		type(ll val) : left(val), right(val), all(val), sum(val) {}
		type(ll l, ll r, ll a, ll s) : left(l), right(r), all(a), sum(s) {}
	};
	static type id() { return type(); }
	static type op(const type& l, const type & r) {
		return type(max(l.left, l.sum + r.left), max(r.right, r.sum + l.right), max({ l.all, r.all, l.right + r.left }), l.sum + r.sum);
	}
};

struct seg_node {
	using M = RMS;
	using T = typename M::type;
	using U = int;

	T val;

private:
	int size;
	bool flag;
	U lazy;

public:
	seg_node() : val(), size(0), flag(false) {}
	void init_leaf(const T& v) {
		val = v;
		size = 1;
	}
	void init_non_leaf(const seg_node& l, const seg_node& r) {
		val = M::op(l.val, r.val);
		size = l.size + r.size;
	}
	void update(U v) {
		val = v > 0 ? T(v * size, v * size, v * size, v * size)
			: T(v, v, v, v * size);
		lazy = v;
		flag = true;
	}
	void push(seg_node& l, seg_node& r) {
		if (!flag) return;
		l.update(lazy);
		r.update(lazy);
		flag = false;
	}
	bool is_updated() const {
		return flag;
	}

};

class segment_tree {
	using M = typename seg_node::M;
	using T = typename seg_node::T;
	using U = typename seg_node::U;
	const int h, n;
	vector<seg_node> data;
	void push(int node) {
		data[node].push(data[node << 1], data[(node << 1) | 1]);
	}
	void update(int node) {
		data[node].val = M::op(data[node << 1].val, data[(node << 1) | 1].val);
	}
public:
	segment_tree(int n_)
		: h(ceil(log2(n_))), n(1 << h), data(n * 2) {}
	segment_tree(int n_, T v1)
		: h(ceil(log2(n_))), n(1 << h), data(n * 2) {
		for (int i = 0; i < n_; i++)
			data[i + n].init_leaf(v1);
		for (int i = n - 1; i >= 1; i--)
			data[i].init_non_leaf(data[i << 1], data[(i << 1) | 1]);
	}
	segment_tree(const vector<T>& data_)
		: h(ceil(log2(data_.size()))), n(1 << h), data(n * 2) {
		for (int i = 0; i < (int)data_.size(); i++)
			data[i + n].init_leaf(data_[i]);
		for (int i = n - 1; i >= 1; i--)
			data[i].init_non_leaf(data[i << 1], data[(i << 1) | 1]);
	}
	void update(int l, int r, U val) {
		l += n, r += n;
		for (int i = h; i > 0; i--) push(l >> i), push(r >> i);
		int tl = l, tr = r;
		r++;
		while (l < r) {
			if (l & 1) data[l++].update(val);
			if (r & 1) data[--r].update(val);
			l >>= 1; r >>= 1;
		}
		while (tl >>= 1, tr >>= 1, tl) {
			if (!data[tl].is_updated()) update(tl);
			if (!data[tr].is_updated()) update(tr);
		}
	}
	T find(int l, int r) {
		l += n, r += n;
		for (int i = h; i > 0; i--) push(l >> i), push(r >> i);
		r++;
		T res1 = M::id(), res2 = M::id();
		while (l < r) {
			if (l & 1) res1 = M::op(res1, data[l++].val);
			if (r & 1) res2 = M::op(data[--r].val, res2);
			l >>= 1; r >>= 1;
		}
		return M::op(res1, res2);
	}
};

class heavy_light_decomposition {
	const int n;
	vector<vector<int>> g;
	vector<int> in, out, size, head, par, dep, inv;
	int it;
	void erase_par(int v, int prev) {
		par[v] = prev;
		for (auto& u : g[v]) {
			if (u == g[v].back()) break;
			if (u == prev) swap(u, g[v].back());
			erase_par(u, v);
		}
		g[v].pop_back();
	}
	void dfs1(int v) {
		for (auto& u : g[v]) {
			dfs1(u);
			size[v] += size[u];
			if (size[u] > size[g[v][0]]) swap(u, g[v][0]);
		}
	}
	void dfs2(int v) {
		in[v] = it++;
		inv[in[v]] = v;
		for (auto u : g[v]) {
			head[u] = (u == g[v][0] ? head[v] : u);
			dep[u] = dep[v] + (u != g[v][0]);
			dfs2(u);
		}
		out[v] = it;
	}
public:
	heavy_light_decomposition(int n_)
		: n(n_), g(n), in(n, -1), out(n, -1), size(n, 1), head(n), par(n, -1), dep(n), inv(n), it(0) {}
	heavy_light_decomposition(const vector<vector<int>>& G)
		: n(G.size()), g(G), in(n, -1), out(n, -1), size(n, 1), head(n), par(n, -1), dep(n), inv(n), it(0) {}
	void add_edge(int u, int v) {
		g[u].push_back(v);
		g[v].push_back(u);
	}
	void build(int rt = 0) {
		for (auto v : g[rt]) erase_par(v, rt);
		dfs1(rt);
		head[rt] = rt;
		dfs2(rt);
	}
	int get_id(int v) {
		return in[v];
	}
	void path_query(int u, int v, function<void(int, int)> f) {
		while (true) {
			if (in[u] > in[v]) swap(u, v);
			f(max(in[head[v]], in[u]), in[v] + 1);
			if (head[u] == head[v]) return;
			v = par[head[v]];
		}
	}
	void path_query(int u, int v, function<void(int, int, bool)> f) {
		while (true) {
			if (in[u] <= in[v]) {
				f(max(in[head[v]], in[u]), in[v] + 1, false);
				if (head[u] == head[v]) return;
				v = par[head[v]];
			}
			else {
				f(max(in[head[u]], in[v]), in[u] + 1, true);
				if (head[u] == head[v]) return;
				u = par[head[u]];
			}
		}
	}
	void subtree_query(int v, function<void(int, int)> f) {
		f(in[v], out[v]);
	}
	int get_lca(int u, int v) {
		while (true) {
			if (in[u] > in[v]) swap(u, v);
			if (head[u] == head[v]) return u;
			v = par[head[v]];
		}
	}
};

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int N, Q;
	cin >> N >> Q;
	vector<int> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	heavy_light_decomposition hld(N);
	for (int i = 0; i < N - 1; i++) {
		int u, v;
		cin >> u >> v; u--, v--;
		hld.add_edge(u, v);
	}
	hld.build();
	vector<RMS::type> base(N);
	for (int i = 0; i < N; i++) {
		base[hld.get_id(i)] = RMS::type(A[i]);
	}
	segment_tree lst(base);
	while (Q--) {
		int t, a, b, c;
		cin >> t >> a >> b >> c; a--, b--;
		if (t == 1) {
			hld.path_query(a, b, [&](int l, int r) {
				lst.update(l, r - 1, c);
			});
		}
		else {
			RMS::type res1, res2;
			hld.path_query(a, b, [&](int l, int r, bool rev) {
				r--;
				if (rev) {
					auto tmp = lst.find(l, r); swap(tmp.left, tmp.right);
					res1 = RMS::op(res1, tmp);
				}
				else {
					res2 = RMS::op(lst.find(l, r), res2);
				}
			});
			printf("%d\n", (int)RMS::op(res1, res2).all);
		}
	}
	return 0;
}