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 <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <climits>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <time.h>
#include <type_traits>
#include <utility>
#include <vector>

using int32 = std::int_fast32_t;
using int64 = std::int_fast64_t;
using uint32 = std::uint_fast32_t;
using uint64 = std::uint_fast64_t;
using intl32 = std::int_least32_t;
using intl64 = std::int_least64_t;
using uintl32 = std::uint_least32_t;
using uintl64 = std::uint_least64_t;

template<typename Monoid, typename Operand>
class link_cut_tree {
	struct node_t {
		node_t *left, *right, *per;
		Monoid value, sum;
		Operand lazy;
		std::uint_least8_t b;
		// isnotroot reverse haslazy
		node_t() :left(nil), right(nil), per(nullptr), value(Monoid())
			, sum(Monoid()), b(0) {}
		Monoid reflect() {
			if (b & 1) {
				if (b & 2) return ~(sum*lazy);
				return sum*lazy;
			}
			if (b & 2) return ~sum;
			return sum;
		}
		void assign(Operand &data) {
			if (b & 1) lazy = lazy*data;
			else { lazy = data;b |= 1; }
		}
		void push() {
			if (b & 2) {
				std::swap(left, right);
				left->b ^= 2;
				right->b ^= 2;
				value = ~value;
			}
			if (b & 1) {
				value = value*lazy;
				left->assign(lazy);
				right->assign(lazy);
			}
			b &= ~3;
		}
		void propagate() {
			if (per) per->propagate();
			push();
		}
		void splay() {
			node_t *x = this, *pp;
			while (x->b&4) {
				if (!(per->b & 4)) {
					if (per->left == this) {
						per->left = right;
						per->recalc();
						right = per;
					}
					else {
						per->right = left;
						per->recalc();
						left = per;
					}
					x = per;
					per = per->per;
					recalc();
					break;
				}
				x = per->per;
				pp = x->per;
				if (per->left == this) {
					if (x->left == per) {
						x->left = per->right;
						per->left = right;
						per->right = x;
						right = per;
					}
					else {
						x->right = left;
						per->left = right;
						right = per;
						left = x;
					}
				}
				else {
					if (x->right == per) {
						x->right = per->left;
						per->right = left;
						per->left = x;
						left = per;
					}
					else {
						x->left = right;
						per->right = left;
						left = per;
						right = x;
					}
				}
				x->recalc();
				per->recalc();
				recalc();
				per = pp;
				if (pp) {
					if (pp->left == x) {
						pp->left = this;
					}
					else if (pp->right == x) {
						pp->right = this;
					}
				}
			}
			x->b |= 4;
		}
		void expose(node_t *prev) {
			splay();
			right->b &= ~4;
			right = prev;
			recalc();
			if (per)per->expose(this);
			else { b &= ~4; }
		}
		void recalc() {
			sum = value;
			if (left != nil) {
				sum = left->reflect() + sum;
				left->per = this;
			}
			if (right != nil) {
				sum = sum + right->reflect();
				right->per = this;
			}
		}
	};
	static node_t *nil;
	std::vector<node_t> tree;
	void expose(node_t *n) {
		n->propagate();
		n->expose(nil);
		n->splay();
		n->b &= ~4;
		n->recalc();
	}
	struct vis {
		int32 l, r, p, rev;
	};
	std::vector<vis> v;
public:
	link_cut_tree(uint32 size) :tree(size) {}
	link_cut_tree(std::vector<Monoid> &a) :tree(a.size()) {
		for (uint32 i = 0;i < a.size();++i) {
			tree[i].value = tree[i].sum = a[i];
		}
	}
	void link(uint32 child, uint32 per) {
		evert(child);
		tree[child].per = &tree[per];
	}
	void cut(uint32 child) {
		node_t *n = &tree[child];
		expose(n);
		n->left->per = nullptr;
		n->left = nil;
		n->sum = n->value;
	}
	void update(uint32 u, uint32 v, const Operand &data) {
		evert(u);
		expose(&tree[v]);
		tree[v].lazy = data;
		tree[v].b |= 1;
	}
	Monoid path(uint32 u, uint32 v) {
		evert(u);
		expose(&tree[v]);
		return tree[v].sum;
	}
	void evert(uint32 v) {
		expose(&tree[v]);
		tree[v].b ^= 2;
	}
	int32 ch(node_t *n) {
		if (!n) return 100;
		if (n == nil) return -1;
		return n - &tree[0];
	}
	void scan(void) {
		v = std::vector<vis>(tree.size());
		for (uint32 i = 0;i < tree.size();++i) {
			v[i] = { ch(tree[i].left),ch(tree[i].right),ch(tree[i].per),tree[i].b & 2 };
		}
	}
};
template<typename Monoid, typename Operand>
typename link_cut_tree<Monoid, Operand>::node_t *
link_cut_tree<Monoid, Operand>::nil = [] {
	nil = new link_cut_tree<Monoid, Operand>::node_t;
	nil->left = nil;
	nil->right = nil;
	nil->per = nullptr;
	nil->sum = Monoid();
	nil->b = 0;
	return nil;
}();

struct ass {
	intl32 data;
	ass(intl32 a = 0) :data(a) {}
	ass operator*(const ass &other) {
		return other;
	}
};
struct douse {
	intl32 all, l, r, sum, siz;
	douse() {}
	douse(int32 a, int32 lef, int32 rig, int32 s, int32 si) :
		all(a), l(lef), r(rig), sum(s), siz(si) {}
	douse operator~() {
		return douse(all, r, l, sum, siz);
	}
	douse operator+(const douse &other) {
		douse ret;
		ret.all = std::max(std::max(all, other.all), std::max(r + other.l, std::max(r, other.l)));
		ret.r = std::max(other.r, r > 0 ? r + other.sum : other.sum);
		ret.l = std::max(l, other.l > 0 ? sum + other.l : sum);
		ret.sum = sum + other.sum;
		ret.siz = siz + other.siz;
		return ret;
	}
	douse operator*(const ass &other) {
		douse ret;
		ret.all = ret.r = ret.l = other.data > 0 ? other.data*siz : other.data;
		ret.sum = other.data*siz;
		ret.siz = siz;
		return ret;
	}
};

int main(void) {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	uint32 n, q;
	std::cin >> n >> q;
	std::vector<douse> a(n);
	int32 t1;
	for (uint32 i = 0;i < n;++i) {
		std::cin >> t1;
		a[i] = douse(t1, t1, t1, t1, 1);
	}
	link_cut_tree<douse, ass> L(a);
	uint32 t2, t3;
	for (uint32 i = 0;i < n - 1;++i) {
		std::cin >> t2 >> t3;
		L.link(t2 - 1, t3 - 1);
	}
	uint32 t4;
	for (uint32 i = 0;i < q;++i) {
		//L.scan();
		std::cin >> t2 >> t3 >> t4 >> t1;
		if (t2 == 1) {
			L.update(t3 - 1, t4 - 1, ass(t1));
		}
		else {
			std::cout << L.path(t3 - 1, t4 - 1).all << "\n";
		}
	}
	return 0;
}