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>
#define int long long
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
const int MAX_N=200000;
int N,Q;
int par[MAX_N][18];
int p[MAX_N];
int depth[MAX_N];

void genlca(){
	rep(i,N) par[i][0]=p[i];
	for(int i=1;i<=17;i++){
		rep(v,N){
			if(par[v][i-1]==-1) par[v][i]=-1;
			else par[v][i]=par[par[v][i-1]][i-1];
		}
	}
}
typedef pair<int,int> P;
P lca(int u,int v){
	bool swapped=0;
	if(depth[u]<depth[v]){
		swap(u,v);
		swapped=1;
	}
	int d=depth[u]-depth[v];
	rep(i,18){
		if((d>>i)&1) u=par[u][i];
	}
	if(u==v) return P(u,-1);
	for(int i=18-1;i>=0;i--){
		if(par[u][i]!=par[v][i]){
			u=par[u][i];
			v=par[v][i];
		}
	}
	if(!swapped) return P(par[v][0],v);
	else return P(par[v][0],u);
}

struct Node{
	int mx,l,r,sum;
	Node(){mx=-1e9,l=-1e9,r=-1e9,sum=0;}
};
Node merge(Node a,Node b){
	Node ret;
	ret.sum=a.sum+b.sum;
	ret.l=max(a.l,a.sum+b.l);
	ret.r=max(b.r,b.sum+a.r);
	ret.mx=max(a.r+b.l,max(a.mx,b.mx));
	return ret;
}
Node flip(Node a){
	swap(a.l,a.r);
	return a;
}
void shownode(Node a){
	printf("l=%d,r=%d,mx=%d,sum=%d\n",a.l,a.r,a.mx,a.sum);
}
struct segtree{
	int getp2(int x){
		int p=1;
		while(p<x) p*=2;
		return p;
	}
	segtree(int N):N(N),p2(getp2(N)),seg(p2*2),same(p2*2),val(p2*2) {}
	int N;
	int p2;
	vector<Node> seg;
	vector<bool> same;
	vector<int> val;
	void dosame(int k,int v,int len){
		if(len==0) return;
		same[k]=1,val[k]=v;
		// show(k);
		// show(v);
		// show(len);
		// puts("");
		if(v>=0) seg[k].l=seg[k].r=seg[k].mx=seg[k].sum=v*len;
		else seg[k].l=seg[k].r=seg[k].mx=v,seg[k].sum=v*len;
//		else seg[k].l=seg[k].r=seg[k].mx=v,seg[k].sum=v*len;
	}
	Node calc(int a,int b,int l,int r,int k){
		if(r<=a||b<=l) return Node();
		if(a<=l&&r<=b) return seg[k];
		if(same[k]){
			dosame(k*2,val[k],(r-l)/2);
			dosame(k*2+1,val[k],(r-l)/2);
		}
		return merge(calc(a,b,l,(l+r)/2,k*2),calc(a,b,(l+r)/2,r,k*2+1));
	}
	Node calc(int a,int b){
		return calc(a,b,0,p2,1);
	}
	void change(int a,int b,int l,int r,int k,int v){
		if(r<=a||b<=l) return;
		if(a<=l&&r<=b){
			dosame(k,v,r-l);
			return;
		}
		if(same[k]){
			dosame(k*2,val[k],(r-l)/2);
			dosame(k*2+1,val[k],(r-l)/2);
		}
		same[k]=0;
		change(a,b,l,(l+r)/2,k*2,v);
		change(a,b,(l+r)/2,r,k*2+1,v);
		seg[k]=merge(seg[k*2],seg[k*2+1]);
	}
	void change(int a,int b,int v){
		change(a,b,0,p2,1,v);
	}
};

int w[MAX_N];
int topo[MAX_N];
int sz[MAX_N];
int hchild[MAX_N];
int chainid[MAX_N];	//vertex->chainid
int top[MAX_N];	//chainid->top
vector<int> G[MAX_N];
void bfs(int s){
	bool vis[MAX_N]={};
	queue<int> que;
	que.push(s);
	int cnt=0;
	while(!que.empty()){
		int t=que.front();
		que.pop();
		vis[t]=1;
		topo[cnt++]=t;
		rep(i,G[t].size()){
			int v=G[t][i];
			if(!vis[v]) que.push(v);
			else{
				p[t]=v;
				G[t].erase(G[t].begin()+i);
				i--;
				continue;
			}
		}
	}
}
void dfs(int v){
	sz[v]=1;
	int id=-1;
	for(int u:G[v]){
		sz[v]+=sz[u];
		if(id<0||sz[u]>sz[id]) id=u;
	}
	hchild[v]=id;
}

vector<segtree> chains;

Node calcall(int T,int B){
	Node ret;
	while(true){
		segtree &seg=chains[chainid[B]];
		int t=top[chainid[B]];
		if(depth[t]<=depth[T]){
			int d1=depth[B]-depth[t];
			int d2=depth[T]-depth[t];
			ret=merge(ret,seg.calc(seg.N-1-d1,seg.N-d2));
/*			show(t);
			show(B);
			show(T);
			show(d1);
			show(d2);
			show(N-1-d1);
			show(seg.N-d2);*/
			return ret;
		}
		int d=depth[B]-depth[t];
		ret=merge(ret,seg.calc(seg.N-1-d,seg.N));
		B=p[t];
	}
}
void changeall(int T,int B,int v){
	while(true){
		segtree &seg=chains[chainid[B]];
		int t=top[chainid[B]];
		if(depth[t]<=depth[T]){
			int d1=depth[B]-depth[t];
			int d2=depth[T]-depth[t];
			seg.change(seg.N-1-d1,seg.N-d2,v);
			return;
		}
		int d=depth[B]-depth[t];
		seg.change(seg.N-1-d,seg.N,v);
		B=p[t];
	}
}
signed main(){
	cin>>N>>Q;
	rep(i,N) cin>>w[i];
	rep(i,N-1){
		int a,b;
		cin>>a>>b;
		a--,b--;
		G[a].pb(b);
		G[b].pb(a);
	}
	bfs(0);
//	rep(i,N) show(topo[i]);
	for(int i=N-1;i>=0;i--) dfs(topo[i]);
	rep1(i,N-1){
		int v=topo[i];
		depth[v]=depth[p[v]]+1;
	}
	p[0]=-1;
//	rep(i,N) show(p[i]);
	int C=0;
	bool vis[MAX_N]={};
	rep(i,N){
		int v=topo[i];
		if(!vis[v]){
			top[C]=v;
			vector<int> vc;
			int u=v;
			while(u>=0){
				vc.pb(u);
				vis[u]=1;
				chainid[u]=C;
				u=hchild[u];
			}
			int Nc=vc.size();
			segtree seg(Nc);
//			show(Nc);
			rep(j,Nc){
				seg.change(j,j+1,w[ vc[Nc-1-j] ]);
//				show(j);
//				show(vc[Nc-1-j]);
//				show(w [vc[Nc-1-j] ]);

			}
			chains.pb(seg);
			C++;
		}
	}
//	show(C);
	genlca();
//	rep(i,N) show(depth[i]);
//	show(p.fs);
//	show(p.sc);
	rep(tt,Q){
		int t,a,b,c;
		cin>>t>>a>>b>>c;
		a--,b--;
		P p=lca(a,b);
//		show(p.fs);
//		show(p.sc);
		if(t%2){
			if(p.sc==-1){
				if(b==p.fs) swap(a,b);
				changeall(a,b,c);
			}else{
				changeall(p.fs,a,c);
				changeall(p.sc,b,c);
			}
		}else{
			if(p.sc==-1){
				if(b==p.fs) swap(a,b);
//				show(a);
//				show(b);
//				shownode(calcall(a,b));
				cout<<calcall(a,b).mx<<endl;
			}else{
				Node x=calcall(p.fs,a);
				Node y=calcall(p.sc,b);
//				show(a);
//				show(p.fs);
//				shownode(x);
//				show(b);
//				show(p.sc);
//				shownode(y);
				cout<<merge(x,flip(y)).mx<<endl;
			}
		}
	}
}