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:
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
#include <random>
#include <cassert>
using namespace std;

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<int, ll> i_ll;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
typedef vector<int> vi;
struct edge { int v; ll w; };

const int MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;
ll INF = INT_MAX;

struct data { ll sum, mi, ma, ans; };

void show(data x) {
	cout << x.sum << ' ' << x.mi << ' ' << x.ma << ' ' << x.ans << endl;
}

data f(data x, data y) {
	data z;
	z.sum = x.sum + y.sum;
	z.mi = min(x.mi, x.sum + y.mi);
	z.ma = max(x.ma, x.sum + y.ma);
	z.ans = max(max(x.ans, y.ans), x.sum + y.ma - x.mi);
	return z;
}

struct segtree {
	segtree *lch, *rch;
	int N, val;
	data x;
	segtree(int _N) : N(_N), val(INF), x({0, 0, 0, 0}) {
		if (N == 1) return;
		int n = N / 2;
		lch = new segtree(n);
		rch = new segtree(N - n);
	}
	data get(int l, int r) {
		if (r <= 0 || N <= l) return data{0, INF, -INF, -INF};
		if (l <= 0 && N <= r) return x;
		int n = N / 2;
		if (val != INF) {
			lch->set(0, n, val); rch->set(0, N - n, val);
			val = INF;
		}
		return f(lch->get(l, r), rch->get(l - n, r - n));
	}
	void set(int l, int r, int _val) {
		if (r <= 0 || N <= l) return;
		if (l <= 0 && N <= r) {
			val = _val;
			x = data{N * val, min(0, (N - 1) * val), max(val, N * val), max(val, N * val)};
			return;
		}
		int n = N / 2;
		if (val != INF) {
			lch->set(0, n, val); rch->set(0, N - n, val);
			val = INF;
		}
		lch->set(l, r, _val); rch->set(l - n, r - n, _val);
		x = f(lch->x, rch->x);
	}
};

struct hl_decomp {
	int N, M;
	vector<vi> G;
	vi sz, id, par, dep, dep_l, dep_r;
	vector<segtree*> st;
	hl_decomp(int _N, vector<vi> _G)
		: N(_N), G(_G), sz(N), id(N), par(N), dep(N) {
		dfs_sz(0, -1);
		dfs_decomp(0, -1);
		M = 1; par[0] = -1; dfs_decomp(0, -1);
		dep_l.assign(M, N); dep_r.assign(M, 0); dfs_dep(0, -1);
		st.resize(M);
		rep(i, M) st[i] = new segtree(dep_r[i] - dep_l[i]);
	}
	void dfs_sz(int u, int p) {
		sz[u] = 1;
		for (int v: G[u]) if (v != p) {
			dfs_sz(v, u);
			sz[u] += sz[v];
		}
	}
	void dfs_decomp(int u, int p) {
		int v0 = -1;
		for (int v: G[u]) if (v != p)
			if (v0 == -1 || sz[v] > sz[v0]) v0 = v;
		for (int v: G[u]) if (v != p) {
			if (v == v0) {
				id[v] = id[u];
				par[v] = par[u];
			}
			else {
				id[v] = M++;
				par[v] = u;
			}
			dfs_decomp(v, u);
		}
	}
	void dfs_dep(int u, int p) {
		int i = id[u];
		dep_l[i] = min(dep_l[i], dep[u]);
		dep_r[i] = max(dep_r[i], dep[u] + 1);
		for (int v: G[u]) if (v != p) {
			dep[v] = dep[u] + 1;
			dfs_dep(v, u);
		}
	}
	int lca(int u, int v) {
		while (id[u] != id[v]) {
			int _u = par[u], _v = par[v];
			if (_u == -1) v = _v;
			else if (_v == -1) u = _u;
			else if (dep[_u] >= dep[_v]) u = _u;
			else v = _v;
		}
		return dep[u] < dep[v] ? u : v;
	}
	ll get(int u, int v) {
		int w = lca(u, v);
		data z1 = {0, INF, -INF, -INF};
		{
			for (; id[u] != id[w]; u = par[u]) {
				int i = id[u];
				z1 = f(st[i]->get(0, dep[u] - dep_l[i] + 1), z1);
			}
			int i = id[u];
			z1 = f(st[i]->get(dep[w] - dep_l[i], dep[u] - dep_l[i] + 1), z1);
		}
		data z2 = {0, INF, -INF, -INF};
		{
			for (; id[v] != id[w]; v = par[v]) {
				int i = id[v];
				z2 = f(st[i]->get(0, dep[v] - dep_l[i] + 1), z2);
			}
			int i = id[v];
			z2 = f(st[i]->get(dep[w] - dep_l[i] + 1, dep[v] - dep_l[i] + 1), z2);
		}
		return max(max(z1.ans, z2.ans), z1.ma + z2.ma);
	}
	void set(int u, int v, int val) {
		int w = lca(u, v);
		{
			for (; id[u] != id[w]; u = par[u]) {
				int i = id[u];
				st[i]->set(0, dep[u] - dep_l[i] + 1, val);
			}
			int i = id[u];
			st[i]->set(dep[w] - dep_l[i], dep[u] - dep_l[i] + 1, val);
		}
		{
			for (; id[v] != id[w]; v = par[v]) {
				int i = id[v];
				st[i]->set(0, dep[v] - dep_l[i] + 1, val);
			}
			int i = id[v];
			st[i]->set(dep[w] - dep_l[i] + 1, dep[v] - dep_l[i] + 1, val);
		}
	}
};

int main() {
	int N, Q; cin >> N >> Q;
	vector<int> a(N);
	rep(u, N) scanf("%d", &a[u]);
	vector<vector<int> > G(N);
	rep(i, N - 1) {
		int u, v; scanf("%d%d", &u, &v);
		u--; v--;
		G[u].pb(v); G[v].pb(u);
	}
	hl_decomp hl(N, G);
	rep(u, N) hl.set(u, u, a[u]);
	while (Q--) {
		int q, u, v, w;
		scanf("%d%d%d%d", &q, &u, &v, &w);
		u--; v--;
		if (q == 1) hl.set(u, v, w);
		if (q == 2) printf("%lld\n", hl.get(u, v));
	}
}