#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;
}



Measured memory_bytes: 59368