#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

const long long INF = LLONG_MAX / 4;

class Data
{
public:
    long long sum, maxSum, left, right;
    Data(){
        sum = maxSum = 0;
        left = right = -INF;
    }
    Data(long long sum, long long maxSum, long long left, long long right){
        this->sum    = sum;
        this->maxSum = maxSum;
        this->left   = left;
        this->right  = right;
    }
};

class SegmentTree
{
public:
    typedef Data T1;
    typedef long long T2;
    // ??????????????????????????\???????????¶?????????????????¨
    //     uniteData(v, INIT_DATA) == v
    static const T1 INIT_DATA;

    // 2????????????????¨??????????v1,v2???????????????
    // ??????2?????????????????±????????????????????????????¨???????????????????
    T1 uniteData(T1 v1, T1 v2){
        T1 ans;
        ans.sum    = v1.sum + v2.sum;
        ans.maxSum = max({v1.maxSum, v2.maxSum, v1.right + v2.left});
        ans.left   = max(v1.left, v1.sum + v2.left);
        ans.right  = max(v2.right, v1.right + v2.sum);
        return ans;
    }

private:
    // ?????¶?????????????????\???????????¶?????????????????¨
    //     updateData(prev, size, INIT_DELAY) == prev
    //     updateDelay(x, INIT_DELAY) == x
    static const T2 INIT_DELAY;

    // ?????????len???????????????????????????????¨??????????prev???????????????
    // ????????????????´???????????????????x?????¨????????´??°??????????????¨?????????????¨???????????????????
    T1 updateData(T1 prev, int len, T2 x){
        if(x == INF)
            return prev;
        else if(x < 0)
            return Data(x*len, x, x, x);
        else
            return Data(x*len, x*len, x*len, x*len);
    }
    // ???????????????x1,x2?????????2????????´??°????????????????????¨????????´??????????????????
    // ??????????????????????????????1????????´??°?????????????????????????????????
    T2 updateDelay(T2 x1, T2 x2){
        if(x2 == INF)
            return x1;
        else
            return x2;
    }

    int n;
    vector<T1> data;
    vector<T2> delay;
    void updateTree(int a, int b, int k, int l, int r, T2 x){
        if(a <= l && r <= b){
            data[k] = updateData(data[k], r - l + 1, x);
            delay[k] = updateDelay(delay[k], x);
        }
        else if(a <= r && l <= b){
            int len = (r - l + 1) / 2;
            for(int i=0; i<2; ++i){
                data[k*2+1+i] = updateData(data[k*2+1+i], len, delay[k]);
                delay[k*2+1+i] = updateDelay(delay[k*2+1+i], delay[k]);
            }
            delay[k] = INIT_DELAY;
            updateTree(a, b, k*2+1, l, (l+r)/2, x);
            updateTree(a, b, k*2+2, (l+r+1)/2, r, x);
            data[k] = uniteData(data[k*2+1], data[k*2+2]);
        }
    }
    T1 getValue(int a, int b, int k, int l, int r){
        if(a <= l && r <= b){
            return data[k];
        }
        else if(a <= r && l <= b){
            int len = (r - l + 1) / 2;
            for(int i=0; i<2; ++i){
                data[k*2+1+i] = updateData(data[k*2+1+i], len, delay[k]);
                delay[k*2+1+i] = updateDelay(delay[k*2+1+i], delay[k]);
            }
            delay[k] = INIT_DELAY;
            T1 v1 = getValue(a, b, k*2+1, l, (l+r)/2);
            T1 v2 = getValue(a, b, k*2+2, (l+r+1)/2, r);
            return uniteData(v1, v2);
        }
        else{
            return INIT_DATA;
        }
    }
public:
    SegmentTree(int n0){
        n = 1;
        while(n < n0)
            n *= 2;
        data.assign(2*n-1, INIT_DATA);
        delay.assign(2*n-1, INIT_DELAY);
    }
    SegmentTree(const vector<T1>& v) : SegmentTree((int)v.size()){
        for(unsigned i=0; i<v.size(); ++i)
            data[n-1+i] = v[i];
        for(int k=n-2; k>=0; --k)
            data[k] = uniteData(data[k*2+1], data[k*2+2]);
    }
    // ??????[a,b]???????´???????????????????x???????????´??°??????????????¨
    void update(int a, int b, T2 x){
        updateTree(a, b, 0, 0, n-1, x);
    }
    // ??????[a,b]????¨???????????????????
    T1 get(int a, int b){
        return getValue(a, b, 0, 0, n-1);
    }
    T1 get(int a, int b, T1 leftPrev, T1 rightPrev){
        return uniteData(uniteData(leftPrev, get(a, b)), rightPrev);
    }
};
const SegmentTree::T1 SegmentTree::INIT_DATA(0, -INF, -INF, -INF);
const SegmentTree::T2 SegmentTree::INIT_DELAY = INF;

class HeavyLightDecomposition
{
private:
    typedef SegmentTree::T1 T1;
    typedef SegmentTree::T2 T2;
    vector<SegmentTree> st;

    void addDataStructure(int n){
        st.push_back(SegmentTree(n));
    }
    void addDataStructure(const vector<T1>& init){
        st.push_back(SegmentTree(init));
    }
    void updateDataStructure(int i, int a, int b, T2 x){
        st[i].update(a, b, x);
    }
    T1 getDataStructure(int i, int a, int b, T1 leftPrev, T1 rightPrev){
        return st[i].get(a, b, leftPrev, rightPrev);
    }
    T1 reverseData(T1 x){
        swap(x.left, x.right);
        return x;
    }

    vector<int> depth;
    vector<int> parent;
    vector<vector<int> > node;
    vector<pair<int, int> > index;

    pair<int, int> dfs(const vector<vector<int> >& edges, int curr, int prev)
    {
        if(prev != -1){
            depth[curr] = depth[prev] + 1;
            parent[curr] = prev;
        }

        int sum = 1;
        pair<int, int> p(-1, -1);
        for(int next : edges[curr]){
            if(next == prev)
                continue;
            pair<int, int> p2 = dfs(edges, next, curr);
            sum += p2.first;
            p = max(p, p2);
        }

        if(p.first == -1){
            p.second = node.size();
            node.resize(p.second + 1);
        }
        node[p.second].push_back(curr);
        return make_pair(sum, p.second);
    }
public:
    HeavyLightDecomposition(const vector<vector<int> >& edges, int root)
    {
        int n = edges.size();
        depth.assign(n, 0);
        parent.assign(n, -1);
        dfs(edges, root, -1);
        index.resize(n);
        for(unsigned i=0; i<node.size(); ++i){
            for(unsigned j=0; j<node[i].size(); ++j)
                index[node[i][j]] = make_pair(i, j);
            addDataStructure(node[i].size());
        }
    }
    HeavyLightDecomposition(const vector<vector<int> >& edges, int root, const vector<T1>& init)
    {
        int n = edges.size();
        depth.assign(n, 0);
        parent.assign(n, -1);
        dfs(edges, root, -1);
        index.resize(n);
        for(unsigned i=0; i<node.size(); ++i){
            vector<T1> v(node[i].size());
            for(unsigned j=0; j<node[i].size(); ++j){
                index[node[i][j]] = make_pair(i, j);
                v[j] = init[node[i][j]];
            }
            addDataStructure(v);
        }
    }
    void update(int a, int b, int x){
        while(index[a].first != index[b].first){
            int a2 = node[index[a].first].back();
            int b2 = node[index[b].first].back();
            if(depth[a2] < depth[b2]){
                swap(a, b);
                swap(a2, b2);
            }
            updateDataStructure(index[a].first, index[a].second, index[a2].second, x);
            a = parent[a2];
        }
        if(depth[a] < depth[b])
            swap(a, b);
        updateDataStructure(index[a].first, index[a].second, index[b].second, x);
    }
    T1 get(int a, int b){
        T1 leftPrev  = SegmentTree::INIT_DATA;
        T1 rightPrev = SegmentTree::INIT_DATA;
        while(index[a].first != index[b].first){
            int a2 = node[index[a].first].back();
            int b2 = node[index[b].first].back();
            if(depth[a2] > depth[b2]){
                leftPrev = getDataStructure(index[a].first, index[a].second, index[a2].second, leftPrev, SegmentTree::INIT_DATA);
                a = parent[a2];
            }
            else{
                rightPrev = getDataStructure(index[b].first, index[b].second, index[b2].second, rightPrev, SegmentTree::INIT_DATA);
                b = parent[b2];
            }
        }
        if(depth[a] > depth[b]){
            return getDataStructure(index[a].first, index[a].second, index[b].second, leftPrev, reverseData(rightPrev));
        }
        else{
            T1 ans = getDataStructure(index[a].first, index[b].second, index[a].second, rightPrev, reverseData(leftPrev));
            return reverseData(ans);
        }
    }
};

int main()
{
    int n, q;
    cin >> n >> q;
    vector<Data> w(n);
    for(int i=0; i<n; ++i){
        int a;
        cin >> a;
        w[i] = Data(a, a, a, a);
    }

    vector<vector<int> > edges(n);
    for(int i=0; i<n-1; ++i){
        int s, e;
        cin >> s >> e;
        -- s;
        -- e;
        edges[s].push_back(e);
        edges[e].push_back(s);
    }
    HeavyLightDecomposition hl(edges, 0, w);

    while(--q >= 0){
        int t, a, b, c;
        cin >> t >> a >> b >> c;
        -- a;
        -- b;
        if(t == 1)
            hl.update(a, b, c);
        else
            cout << hl.get(a, b).maxSum << endl;
    }

    return 0;
}

Measured memory_bytes: 63320