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;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

template<typename M>
class LinkCutTree {
public:
    using T = typename M::T;
    using E = typename M::E;

    struct node {
        int sz;
        T val, sum;
        E lazy;
        node *left, *right, *par;
        bool rev;
        node() : sz(1), val(M::T0()), sum(M::T0()), lazy(M::E0()),
            left(nullptr), right(nullptr), par(nullptr), rev(false) {}
        node(T _val) : sz(1), val(_val), sum(_val), lazy(M::E0()),
            left(nullptr), right(nullptr), par(nullptr), rev(false) {}
        inline bool isRoot() const {
            return (!par) || (par->left != this && par->right != this);
        }
        void push() {
            if(lazy != M::E0()) {
                val = M::g(val, lazy, 1), sum = M::g(sum, lazy, sz);
                if(left) left->lazy = M::h(left->lazy, lazy);
                if(right) right->lazy = M::h(right->lazy, lazy);
                lazy = M::E0();
            }
            if(rev) {
                swap(left, right);
                sum = M::s(sum);
                if(left) left->rev ^= true;
                if(right) right->rev ^= true;
                rev = false;
            }
        }
        void eval() {
            sz = 1, sum = val;
            if(left) left->push(), sz += left->sz, sum = M::f(left->sum, sum);
            if(right) right->push(), sz += right->sz, sum = M::f(sum, right->sum);
        }
    };
 
private:
    void rotate(node* u, bool right) {
        node *p = u->par, *g = p->par;
        if(right) {
            if((p->left = u->right)) u->right->par = p;
            u->right = p, p->par = u;
        } else {
            if((p->right = u->left)) u->left->par = p;
            u->left = p, p->par = u;
        }
        p->eval(), u->eval(), u->par = g;
        if(!g) return;
        if(g->left == p) g->left = u;
        if(g->right == p) g->right = u;
        g->eval();
    }
    // uをsplay木の根にする
    void splay(node* u) {
        while(!u->isRoot()) {
            node *p = u->par, *gp = p->par;
            if(p->isRoot()) { // zig
                p->push(), u->push();
                rotate(u, (u == p->left));
            } else {
                gp->push(), p->push(), u->push();
                bool flag = (u == p->left);
                if((u == p->left) == (p == gp->left)) { // zig-zig
                    rotate(p, flag), rotate(u, flag);
                } else { // zig-zag
                    rotate(u, flag), rotate(u, !flag);
                }
            }
        }
        u->push();
    }
    // 頂点uから根へのパスをつなげる
    node* expose(node* u) {
        node* last = nullptr;
        for(node* v = u; v; v = v->par) {
            splay(v);
            v->right = last;
            v->eval();
            last = v;
        }
        splay(u);
        return last;
    }
    void evert(node* u) {
        expose(u), u->rev = !(u->rev), u->push();
    }
    bool connected(node *u, node *v) {
        expose(u), expose(v);
        return u == v || u->par;
    }
    void link(node *u, node *v) {
        evert(u), u->par = v;
    }
    void cut(node* u) { // uと親の辺を切る
        expose(u), u->left->par = nullptr, u->left = nullptr, u->eval();
    }
    void cut(node* u, node* v) {
        expose(u), expose(v);
        if(u->isRoot()) u->par = nullptr;
        else v->left->par = nullptr, v->left = nullptr, v->eval();
    }
    node* lca(node* u, node* v) {
        expose(u);
        return expose(v);
    }
    int depth(node* u) {
        expose(u);
        return u->sz - 1;
    }
    void toRoot_range(node* u, const E x) {
        expose(u);
        u->lazy = M::h(u->lazy, x), u->push();
    }
    void range(node* u, node* v, const E x) {
        evert(u), expose(v);
        v->lazy = M::h(v->lazy, x), v->push();
    }
    void toRoot_query(node* u) {
        expose(u);
        return u->sum;
    }
    T query(node* u, node* v) {
        evert(u), expose(v);
        return v->sum;
    }
 
public:
    const int n;
    node** arr;
    LinkCutTree(const vector<T> &v) : n(v.size()) { 
        arr = new node*[n];
        REP(i, n) arr[i] = new node(v[i]);
    }
    // ~LinkCutTree(){
    //     REP(i, n) delete arr[i];
    //     delete[] arr;
    // }
    bool connected(int id1, int id2){ return connected(arr[id1], arr[id2]); }
    void link(int id1, int id2){ return link(arr[id1], arr[id2]); }
    void cut(int id){ return cut(arr[id]); } // uと親の辺を切る
    void cut(int id1, int id2){ return cut(arr[id1], arr[id2]); }
    int lca(int id1, int id2){ return static_cast<size_t>(lca(arr[id1], arr[id2]) - arr[0]); }
    void evert(int id){ return evert(arr[id]); }
    int depth(int id){ return depth(arr[id]); }
    void toRoot_range(int id, const E x){ return toRoot_range(arr[id], x); }
    void range(int id1, int id2, const E x){ return range(arr[id1], arr[id2], x); }
    T toRoot_query(int id){ return toRoot_query(arr[id]); }
    T query(int id1, int id2){ return query(arr[id1], arr[id2]); }
};

struct submax { 
    ll lsum, rsum, max, sum;
    submax() {}
    submax(ll a, ll b, ll c, ll d) : lsum(a), rsum(b), max(c), sum(d) {}
};
struct monoid {
    using T = submax;
    using E = ll;
    static T T0() { return submax(-INF, -INF, -INF, 0); }
    static constexpr E E0() { return INF; }
    static T f(const T &x, const T &y) { 
        T ret;
        ret.lsum = max(x.lsum, x.sum+y.lsum);
        ret.rsum = max(y.rsum, x.rsum+y.sum);
        ret.max = max({x.max, y.max, x.rsum+y.lsum});
        ret.sum = x.sum + y.sum;
        return ret; 
    }
    static T g(const T &x, const E &y, int sz) { 
        T ret;
        ret.max = max(y, y*sz);
        ret.sum = y * sz;
        ret.lsum = ret.max;
        ret.rsum = ret.max;
        return ret;
    }
    static E h(const E &x, const E &y) { 
        return y;
    }
    static T s(const T &x) { 
        T ret(x);
        swap(ret.lsum, ret.rsum);
        return ret;
    }
};

int main(void) {
    ll n, q;
    cin >> n >> q;
    vector<ll> w(n);
    REP(i, n) cin >> w[i];
    vector<submax> init(n);
    REP(i, n) init[i] = submax(w[i], w[i], w[i], w[i]);
    LinkCutTree<monoid> lct(init);
    REP(i, n-1) {
        ll u, v;
        cin >> u >> v;
        u--, v--;
        lct.link(u, v);
    }
    REP(i, q) {
        ll t, a, b, c;
        cin >> t >> a >> b >> c;
        a--, b--;
        if(t == 1) {
            lct.range(a, b, c);
        } else {
            cout << lct.query(a, b).max << "\n";
        }
    }

    return 0;
}