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>
using namespace std;

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int INF=1001001001001001001ll;

struct node{
    int v,l,r,s;
    node(int a){
        v=l=r=s=a;
    }
    node(int v,int l,int r,int s):v(v),l(l),r(r),s(s){}
    node(){
        v=l=r=-INF;
        s=0;
    }
};
node operator+(const node &a,const node &b){
    node c;
    c.v=max(max(a.v,b.v),a.r+b.l);
    c.s=a.s+b.s;
    c.l=max(a.l,a.s+b.l);
    c.r=max(b.r,b.s+a.r);
    return c;
}

struct segtree{
    static const int SEG=1<<18;
    vint put;
    vector<node>dat;
    segtree():put(SEG*2,INF),dat(SEG*2){}

    inline void push(int k,int l,int r){
        if(put[k]==INF)return;
        if(put[k]>=0)dat[k]=node(put[k]*(r-l));
        else dat[k]=node(put[k],put[k],put[k],put[k]*(r-l));

        if(k<SEG-1){
            put[k*2+1]=put[k];
            put[k*2+2]=put[k];
        }
        put[k]=INF;
    }

    void update(int a,int b,int x,int k=0,int l=0,int r=SEG){
        push(k,l,r);
        if(r<=a||b<=l)return;
        if(a<=l&&r<=b){
            put[k]=x;
            push(k,l,r);
            return;
        }
        update(a,b,x,k*2+1,l,(l+r)/2);
        update(a,b,x,k*2+2,(l+r)/2,r);
        dat[k]=dat[k*2+1]+dat[k*2+2];
    }
    node query(int a,int b,int k=0,int l=0,int r=SEG){
        push(k,l,r);
        if(r<=a||b<=l)return node();
        if(a<=l&&r<=b)return dat[k];
        return query(a,b,k*2+1,l,(l+r)/2)+query(a,b,k*2+2,(l+r)/2,r);
    }
};

const int SIZE=222222;

int N,Q;
int W[SIZE];
vint G[SIZE];

int par[SIZE],dep[SIZE],hev[SIZE],pos[SIZE],head[SIZE],sz[SIZE];
segtree seg;

void dfs(){
    vint vs={0};
    par[0]=-1;
    dep[0]=0;
    rep(i,N){
        int v=vs[i];
        for(auto u:G[v]){
            if(u==par[v])continue;
            par[u]=v;
            dep[u]=dep[v]+1;
            vs.pb(u);
        }
    }

    for(int i=vs.size()-1;i>=0;i--){
        int v=vs[i];
        sz[v]=1;
        hev[v]=-1;
        int ma=0;
        for(auto u:G[v]){
            if(u==par[v])continue;
            if(ma<sz[u]){
                ma=sz[u];
                hev[v]=u;
            }
            sz[v]+=sz[u];
        }
    }
    /*
    par[v]=p;
    dep[v]=d;
    hev[v]=-1;
    int ma=0,sum=1;
    rep(i,G[v].size()){
        int to=G[v][i];
        if(to==p)continue;
        int tmp=dfs(to,v,d+1);
        if(ma<tmp){
            ma=tmp;
            hev[v]=to;
        }
        sum+=tmp;
    }
    return sum;
    */
}


void init(){
    dfs();
    int idx=0;
    rep(i,N){
        if(~par[i]&&hev[par[i]]==i)continue;
        for(int j=i;~j;j=hev[j]){
            head[j]=i;
            pos[j]=idx++;
        }
    }
    rep(i,N){
        seg.update(pos[i],pos[i]+1,W[i]);
    }
}

void query1(int a,int b,int c){
    while(head[a]!=head[b]){
        if(dep[head[a]]<dep[head[b]])swap(a,b);
        seg.update(pos[head[a]],pos[a]+1,c);
        a=par[head[a]];
    }
    if(dep[a]>dep[b])swap(a,b);
    seg.update(pos[a],pos[b]+1,c);
}

int query2(int a,int b){
    node x,y;
    while(head[a]!=head[b]){
        if(dep[head[a]]>=dep[head[b]]){
            x=seg.query(pos[head[a]],pos[a]+1)+x;
            a=par[head[a]];
        }
        else{
            y=seg.query(pos[head[b]],pos[b]+1)+y;
            b=par[head[b]];
        }
    }

    if(dep[a]>=dep[b]){
        x=seg.query(pos[b],pos[a]+1)+x;
    }
    else{
        y=seg.query(pos[a],pos[b]+1)+y;
    }

    swap(x.l,x.r);
    x=x+y;
    return x.v;
}

signed main(){
    scanf("%lld%lld",&N,&Q);
    rep(i,N)scanf("%lld",&W[i]);

    rep(i,N-1){
        int a,b;
        scanf("%lld%lld",&a,&b);
        a--;b--;
        G[a].pb(b);G[b].pb(a);
    }
    init();

    while(Q--){
        int t,a,b,c;
        scanf("%lld%lld%lld%lld",&t,&a,&b,&c);
        a--;b--;
        if(t==1){
            query1(a,b,c);
        }
        else{
            printf("%lld\n",query2(a,b));
        }
    }
    return 0;
}