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 sz (1<<18)
using namespace std;

const char ch = ' ';

template < typename T >
int SIZE(const T &a) { return a.size(); }

typedef long long ll;
const ll INF = (1LL<<60);

struct data{
  ll ans,lans,rans,sum;
  data(ll a=INF,ll b=INF,ll c=INF,ll d=INF){
    ans=a,lans=b,rans=c,sum=d;
  }
};

data merge(data a,data b){
  if( a.ans == INF ) return b;
  if( b.ans == INF ) return a;
  ll nans=max(a.rans+b.lans,max(a.ans,b.ans));
  ll nlans=max(a.lans,a.sum+b.lans);
  ll nrans=max(b.rans,b.sum+a.rans);
  ll nsum=a.sum+b.sum;
  return data(nans,nlans,nrans,nsum);
}



struct segtree{
  data tree[sz*2];
  bool f[sz*2];
  ll lazy[sz*2];
  
  void init(){
    for(int i=0;i<sz*2;i++){
      tree[i]=data();
      f[i]=false;
    }
  }
  

  void hyoka(int k,int l,int r,ll x){
    ll nsum=x*(r-l);
    ll nans=max(x,nsum);
    tree[k]=data(nans,nans,nans,nsum);
  }
  
  void reflesh(int k,int l,int r){
    int m=(l+r)/2;
    if(f[k]&&r-l>1){
      f[k]=false;
      f[k*2+1]=f[k*2+2]=true;
      lazy[k*2+1]=lazy[k*2+2]=lazy[k];
      hyoka(k*2+1,l,m,lazy[k]);
      hyoka(k*2+2,m,r,lazy[k]);      
    }
    
    if( r-l>1 ){
      int L=k*2+1,R=k*2+2;
      tree[k]=merge(tree[L],tree[R]);
    }
  }

  void update(int a,int b,int k,int l,int r,int x){
    if(b<=l || r<=a) return;
    int m=(l+r)/2;
    reflesh(k,l,r);
    if(a<=l && r <=b){
      f[k]=1;
      lazy[k]=x;
      hyoka(k,l,r,x);
      return;
    }
    update(a,b,k*2+1,l,m,x);
    update(a,b,k*2+2,m,r,x);
    reflesh(k,l,r);
  }
  
  data dfs(int a,int b,int k,int l,int r){
    if(b<=l || r<=a) return data(INF,INF,INF,INF);
    reflesh(k,l,r);
    
    if(a<=l && r <=b) return tree[k];
    int m=(l+r)/2;
    return merge(dfs(a,b,k*2+1,l,m),dfs(a,b,k*2+2,m,r));
  }
  data get(int l,int r){
    return dfs(l,r,0,0,sz);
  }
};


struct edge{
  int to;
  edge(int a){to=a;}
};

typedef vector<int> vint;
typedef vector<edge> node;
typedef vector<node> graph;

void add_udedge(graph &G, int from,int to){
  G[from].emplace_back(to);
  G[to].emplace_back(from);
}

struct HLD{
  graph G;
  int V;
  int root;
  vint parent,depth,size;
  vint head,index,array;
  void Fdfs(int pos,int prev,int d){
    size[pos]=1;
    parent[pos]=prev;
    depth[pos]=d;
    for(int i=0;i< SIZE(G[pos]) ;i++){
      edge e=G[pos][i];
      if(e.to==prev)continue;
      Fdfs(e.to,pos,d+1);
      size[pos]+=size[e.to];
    }
  }
  
  void Sdfs(int pos){
    int target=-1, maxm=-1;
    for(int i=0;i<SIZE(G[pos]);i++){
      edge e=G[pos][i];
      if(e.to==parent[pos])continue;
      if(maxm<size[e.to]){
	target=e.to;
	maxm=size[e.to];
      }
    }
    index[pos]=SIZE(array);
    array.push_back(pos);
    if(target==-1)return;
    head[target]=head[pos];
    Sdfs(target);
    for(int i=0;i<SIZE(G[pos]);i++){
      edge e=G[pos][i];
      if(e.to==parent[pos]||e.to==target)continue;
      Sdfs(e.to);
    }
    
  }

  void solve(const graph &g,int r){
    G=g;
    V=G.size();
    root=r;
    parent=depth=size=vint(V);
    head=index=vint(V);
    array.clear();
    for(int i=0;i<V;i++)head[i]=i;
    Fdfs(r,root,0);
    Sdfs(r);  
  }

  int lca(int a,int b){
    
    while(head[a]!=head[b]){


      int na=head[a];
      int nb=head[b];
      if(depth[na]>depth[nb])a=parent[na];
      else b=parent[nb];


      //      cout<<a<<ch<<b<<ch<<na<<ch<<nb<<endl;
    }


    return depth[a]<depth[b]?a:b;
  }

  void Path2RangesSecond(int a,int c, vint &L, vint &R, bool inC){
    while( head[a]!=head[c] ){
      int na=parent[head[a]];
      L.push_back(index[head[a]]);
      R.push_back(index[a]+1);
      
      a=na;
    }

    if(inC){
      L.push_back(index[c]);
      R.push_back(index[a]+1);
    }else{
      if(c!=a){
	L.push_back(index[c]+1);
	R.push_back(index[a]+1);
      }
    }
    
  }
  
  void Path2Ranges(int a,int b, vint &L, vint &R){
    int c=lca(a,b);
    Path2RangesSecond(a,c,L,R,true);
    int tmp=L.size();
    Path2RangesSecond(b,c,L,R,false);
    reverse(L.begin()+tmp, L.end());
    reverse(R.begin()+tmp, R.end());
  }
};

segtree T;

int main(){
  int n,q;
  cin>>n>>q;
  vint w(n);
  graph G(n);
  for(int i=0;i<n;i++)cin>>w[i];
  for(int i=0,a,b;i<n-1;i++){
    cin>>a>>b;
    a--,b--;
    add_udedge(G,a,b);
  }
  HLD hld;
  T.init();
  hld.solve(G,n/2);


  
  for(int i=0;i<n;i++){
    int id=hld.index[i];
    T.update(id,id+1,0,0,sz,w[i]);
  }
 
  int t,a,b,c;
  while(q--){
    cin>>t>>a>>b>>c;
    a--,b--;
    if(t==1){
      vint L,R;
      hld.Path2Ranges(a,b,L,R);
      
      for(int i=0;i<SIZE(L);i++){
	T.update(L[i],R[i],0,0,sz,c);
      }
      
    }
    else{
      data tmp;

      c=hld.lca(a,b);

      
      vint L,R;

      hld.Path2RangesSecond(a,c,L,R,true);

      
      for(int i=0;i<SIZE(L);i++){
	
	data ex = T.dfs(L[i],R[i],0,0,sz);
	swap( ex.lans , ex.rans );
	tmp = merge( tmp, ex);
      }
      
      L.clear();
      R.clear();
      hld.Path2RangesSecond(b,c,L,R,false);
      reverse(L.begin(),L.end());
      reverse(R.begin(),R.end());

      
      for(int i=0;i<SIZE(L);i++){
	
	data ex = T.dfs(L[i],R[i],0,0,sz);
	tmp = merge( tmp, ex);
      }
      cout<<tmp.ans<<endl;
    }
    
  }
  return 0;
}