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 LinkCutTree{;
    struct Node{
        Node *lp,*rp,*pp;
        int cnt;
        bool rev;
        int val,put;
        node agg;
        Node():lp(0),rp(0),pp(0),rev(0),cnt(1),put(INF){}
        bool isRoot(){
            return !pp||(pp->lp!=this&&pp->rp!=this);
        }

        void push(){
            if(rev){
                swap(lp,rp);
                swap(agg.l,agg.r);
                if(lp)lp->rev^=1;
                if(rp)rp->rev^=1;
            }
            if(put!=INF){
                val=put;
                if(put>=0)agg=node(put*cnt);
                else agg=node(put,put,put,put*cnt);
                if(lp)lp->put=put;
                if(rp)rp->put=put;
            }

            rev=false;
            put=INF;
        }

        void push_all(){
            if(!isRoot())pp->push_all();
            push();
            if(lp)lp->push();
            if(rp)rp->push();
        }

        void update(){
            cnt=(lp?lp->cnt:0)+1+(rp?rp->cnt:0);
            agg=node(val);
            if(lp)agg=lp->agg+agg;
            if(rp)agg=agg+rp->agg;
        }

        void rotR(){
            Node *q=pp,*r=q->pp;
            if((q->lp=rp))rp->pp=q;
            rp=q;q->pp=this;
            if((pp=r)){
                if(r->lp==q)r->lp=this;
                if(r->rp==q)r->rp=this;
            }
            q->update();
            update();
        }

        void rotL(){
            Node *q=pp,*r=q->pp;
            if((q->rp=lp))lp->pp=q;
            lp=q;q->pp=this;
            if((pp=r)){
                if(r->lp==q)r->lp=this;
                if(r->rp==q)r->rp=this;
            }
            q->update();
            update();
        }


        void splay(){
            push_all();
            while(!isRoot()){
                Node *q=pp;
                if(q->isRoot()){
                    if(q->lp==this)rotR();
                    else rotL();
                }
                else{
                    Node *r=q->pp;
                    if(r->lp==q){
                        if(q->lp==this){q->rotR();rotR();}
                        else {rotL();rotR();}
                    }
                    else{
                        if(q->rp==this){q->rotL();rotL();}
                        else{rotR();rotL();}
                    }
                }
            }
        }

        void expose(){
            Node *rp=NULL;
            for(Node *p=this;p;p=p->pp){
                p->splay();
                p->rp=rp;
                rp=p;
                p->update();
            }
            splay();
        }
    };

    Node *nodes;
    LinkCutTree(int n){nodes=new Node[n];}

    //???(v->v??????)?????????
    void cut(int v){
        nodes[v].expose();
        Node *p=nodes[v].lp;
        nodes[v].lp=NULL;
        p->pp=NULL;
        nodes[v].update();
    }

    //???(v->u)?????????
    void link(int v,int u){
        nodes[v].expose();
        nodes[u].expose();
        nodes[v].pp=&nodes[u];
        nodes[u].rp=&nodes[v];
        nodes[u].update();
    }

    void addEdge(int v,int u){
        evert(v);
        link(v,u);
    }

    int lca(int a,int b){
        nodes[a].expose();
        nodes[b].expose();

        bool sameTree=false;
        Node *ret=&nodes[a];
        for(Node *x=&nodes[a];x;x=x->pp){
            if(x->pp&&x->isRoot())ret=x->pp;
            if(x==&nodes[b])sameTree=true;
        }
        return sameTree?(ret-nodes):-1;
    }

    void evert(int v){
        nodes[v].expose();
        nodes[v].rev^=1;
    }

    int findRoot(int v){
        Node *p=&nodes[v];
        p->expose();
        while(p->lp)p=p->lp;
        p->splay();
        return p-nodes;
    }

    void update(int v,int u,int c){
        evert(u);
        nodes[v].expose();
        nodes[v].put=c;
    }

    int query(int v,int u){
        evert(u);
        nodes[v].expose();
        return nodes[v].agg.v;
    }
};

int N,Q;
int W[222222];
void solve(){

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

    LinkCutTree lct(N);
    rep(i,N)lct.nodes[i].val=W[i],lct.nodes[i].agg=node(W[i]);
    rep(i,N-1){
        int a,b;
        scanf("%lld%lld",&a,&b);
        a--;b--;
        lct.addEdge(a,b);
    }

    while(Q--){
        int t,a,b,c;
        scanf("%lld%lld%lld%lld",&t,&a,&b,&c);
        a--;b--;
        if(t==1){
            lct.update(a,b,c);
        }
        else{
            printf("%lld\n",lct.query(a,b));
        }
    }
}

long long esp_org, esp_new;
signed main(){
    const int size = 128*1024*1024;
    void *p = malloc(size);
    esp_new = (long long)p + size - 1;
    __asm__("mov %%rsp, %0" : "=r"(esp_org) : : );
    __asm__("mov %0, %%rsp" : : "r"(esp_new) : );
    solve();
    __asm__("mov %0, %%rsp" : : "r"(esp_org) : );
    free(p);
    return 0;
}