#define NDEBUG
 
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <cassert>
#include <unistd.h>
#include <cstdio>
#include <cstdlib>
#include <stack>
#include <random>
using namespace std;

inline int fastmax(int a, int b) {
    assert(sizeof(int) == 4);
    return a - ((a-b) & (a-b)>>31);
}
inline void fastswap(int &a, int &b) {
    assert(&a == &b);
    a ^= b;
    b ^= a;
    a ^= b;
}
typedef long long ll;
struct LCNode {
    typedef LCNode* NP;
    typedef int D;
    static const int INF = 1LL<<25;
    static LCNode last_d;
    static NP last;
    NP p, l, r;
    int sz;
    int v, sm, lz;
    int lsm, rsm, ma, mv;
    bool rev, lzf;
    LCNode(D v) :p(NULL), l(last), r(last), sz(1),
        v(v), sm(v), rev(false),
        lsm(max(v, 0)), rsm(max(v, 0)), ma(max(v, 0)), mv(v) {}
    LCNode() : l(NULL), r(NULL), sz(0), v(-INF), mv(-INF) {}
    inline int pos() {
        if (p) {
            if (p->l == this) return -1;
            if (p->r == this) return 1;
        }
        return 0;
    }
    inline void rot() {
        NP qq = p->p;
        int pps = p->pos();
        if (p->l == this) {
            p->l = r; r->p = p;
            r = p; p->p = this;
        } else {
            p->r = l; l->p = p;
            l = p; p->p = this;
        }
        p->update(); update();
        p = qq;
        if (!pps) return;
        if (pps == -1) {
            qq->l = this;
        } else {
            qq->r = this;
        }
        qq->update();
    }
    void splay() {
        assert(this != last);
        int ps;
        while ((ps = pos())) {
            int pps = p->pos();
            if (!pps) {
                rot();
            } else if (ps == pps) {
                p->rot(); rot();
            } else {
                rot(); rot();
            }
        }
    }
    void expose() {
        assert(this != last);
        supush();
        NP u = this;
        do {
            u->splay();
        } while ((u = u->p));
        u = last;
        u->p = this;
        do {
            u->p->r = u;
            u->p->update();
            u = u->p;
        } while (u->p);
        splay();
    }
    void push() {
        int lsz = l->sz, rsz = r->sz;
        if (rev) {
            if (lsz) {
                l->revdata();
            }
            if (rsz) {
                r->revdata();
            }
            rev = false;
        }
        if (lzf) {
            if (lsz) {
                l->lzdata(lz);
            }
            if (rsz) {
                r->lzdata(lz);
            }
            lzf = false;
        }
    }
    const static int SS = 200001;
    static NP st[SS];
    static int stc;
    void supush() {
        NP u = this;
        while (u) {
            st[stc++] = u;
            u = u->p;
        }
        while (stc) {
            st[--stc]->push();
        }
    }
    inline void revdata() {
        swap(l, r);
        fastswap(lsm, rsm);
        rev ^= true;
    }
    inline void lzdata(D d) {
        v = mv = d;
        sm = sz*d;
        lsm = rsm = ma = fastmax(0, sm);
        lz = d;
        lzf = true;
    }
    NP update() {
        assert(this != last);
        sz = 1+l->sz+r->sz;
        sm = v+l->sm+r->sm;
        lsm = fastmax(l->lsm, l->sm+v+r->lsm);
        rsm = fastmax(r->rsm, r->sm+v+l->rsm);
        ma = l->rsm+v+r->lsm;
        ma = fastmax(ma, l->ma);
        ma = fastmax(ma, r->ma);
        mv = v;
        mv = fastmax(mv, l->mv);
        mv = fastmax(mv, r->mv);
        return this;
    }
 
    void evert() {
        expose();
        revdata();
    }
};
LCNode LCNode::last_d = LCNode();
LCNode::NP LCNode::last = &last_d;
LCNode::NP LCNode::st[LCNode::SS];
int LCNode::stc = 0;
 
inline int getint() {
    char c;
    int res = 0;
    bool neg = false;
    while (true) {
        c = getchar_unlocked();
        if (c == '-') {
            neg = true;
            break;
        }
        if ('0' <= c && c <= '9') {
            res = c-'0';
            break;
        }
    }
    while (c = getchar_unlocked(), '0' <= c && c <= '9') {
        res *= 10;
        res += c-'0';
    }
    if (neg) res *= -1;
    return res;
}
 
inline void putint(int d) {
    static char buf[10];
    int c = 0;
    bool neg = false;
    if (d < 0) {
        putchar_unlocked('-');
        d *= -1;
    }
    if (!d) {
        putchar_unlocked('0');
        return;
    }
    while (d) {
        buf[c++] = d%10;
        d = d/10;
    }
    while (c--) {
        putchar_unlocked(buf[c]+'0');
    }
}
 
const int MN = 200001;
LCNode tr[MN];
int main() {
    int n = getint(), q = getint();
    for (int i = 0; i < n; i++) {
        int w = getint();
        tr[i] = LCNode(w);
    }
    for (int i = 0; i < n-1; i++) {
        int s = getint(), e = getint(); s--; e--;
        tr[s].evert();
        tr[e].expose();
        tr[s].p = tr+e;
    }
    for (int i = 0; i < q; i++) {
        int t = getint(), a = getint(), b = getint(), c = getint();
        a--; b--;
        if (t <= 1) {
            tr[a].evert();
            tr[b].expose();
            tr[b].lzdata(c);
        } else {
            tr[a].evert();
            tr[b].expose();
            int d;
            if (tr[b].mv < 0) d = tr[b].mv;
            else d = tr[b].ma;
            putint(d);
            putchar_unlocked('\n');
        }
    }
}

Measured memory_bytes: 13576