#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

const ll INF=1e18;

struct State{
    ll sum,lef,rig,ans;
    State():sum(0),lef(-INF),rig(-INF),ans(-INF){}

    void  reset(ll val,int len){
        sum=val*len;
        ans=max(sum,val);
        if(val>=0){
            lef=sum;
            rig=sum;
        }else{
            lef=val;
            rig=val;
        }
    }
};

State merge(State l,State r){
    State res;
    res.sum=l.sum+r.sum;
    res.lef=max(l.lef,l.sum+r.lef);
    res.rig=max(r.rig,r.sum+l.rig);
    res.ans=max(max(l.ans,r.ans),l.rig+r.lef);
    return res;
}

class LazySegmentTree{
private:
  int n;
  vector<ll> lazy;
  vector<State> node;
  State zero;

public:
  LazySegmentTree(vector<ll> v){
      n=1;
      while(n<v.size()) n*=2;
      node.resize(2*n-1);
      lazy.resize(2*n-1,-INF);
      
      for(int i=0;i<v.size();i++) node[i+n-1].reset(v[i],1);
      for(int i=n-2;i>=0;i--) node[i]=merge(node[2*i+1],node[2*i+2]);
  }

  void eval(int k,int l,int r){
      if(lazy[k]!=-INF){
          node[k].reset(lazy[k],r-l);
          if(r-l>1){
              lazy[2*k+1]=lazy[k];
              lazy[2*k+2]=lazy[k];
          }
          lazy[k]=-INF;
      }
  }

  void update(int a,int b,ll x,int k=0,int l=0,int r=-1){
      if(r<0) r=n;
      eval(k,l,r);
      if(b<=l||r<=a) return;
      if(a<=l&&r<=b){
          lazy[k]=x;
          eval(k,l,r);
      }else{
          update(a,b,x,2*k+1,l,(r+l)/2);
          update(a,b,x,2*k+2,(r+l)/2,r);
          node[k]=merge(node[2*k+1],node[2*k+2]);
      }
  }

  State query(int a,int b,int k=0,int l=0,int r=-1){
      if(r<0) r=n;
      eval(k,l,r);
      if(b<=l||r<=a) return zero;
      if(a<=l&&r<=b) return node[k];

      State vl,vr;
      vl=query(a,b,2*k+1,l,(l+r)/2);
      vr=query(a,b,2*k+2,(l+r)/2,r);
      return merge(vl,vr);
  }
};

struct Edge{
    int to,id;
    ll dist;
    Edge(int to,ll dist=1,int id=0):to(to),dist(dist),id(id){}
};

// this class's update method is empty.
struct HeavyLightDecomposition{
    vector<vector<Edge>> g;
    vector<int> in,out,head,par,dep,sz;
    int times;
    int root;

    HeavyLightDecomposition(int V,vector<vector<Edge>> &G,int root=0):
        g(G),in(V),out(V),head(V),par(V),dep(V),sz(V),root(root){
            times=0;
            sz_dfs(root,-1);
            hld_dfs(root,-1);
    }
    
    void sz_dfs(int now,int p){
        par[now]=p;
        sz[now]=1;
        if(p==-1) dep[now]=0;
        else dep[now]=dep[p]+1;

        for(auto &e:g[now]){
            if(e.to==p) continue;
            sz_dfs(e.to,now);
            sz[now]+=sz[e.to];
            if(sz[e.to]>sz[g[now][0].to]) swap(e,g[now][0]);
        }
    }

    void hld_dfs(int now,int p){
        in[now]=times++;
        for(auto e:g[now]){
            if(e.to==p) continue;
            head[e.to]=(e.to == g[now][0].to ? head[now] : e.to);
            hld_dfs(e.to,now);
        }
        out[now]=times;
    }


    int lca(int u,int v){
        for(;;v=par[head[v]]){
            if(in[u]>in[v]) swap(u,v);
            if(head[u]==head[v]) return u;
        }
    }
    int distance(int u,int v){
        return dep[u]+dep[v]-2*dep[lca(u,v)];
    }

    /*ex)
        hld.update(u,x,[&](int a,int b,ll x){
            seg.add(a,b,x);
        });
    */
    template<class T,class G>
    void update(int u,int v,const T &x,const G &g){//辺の時は0を使わない(INFのまま)
        //g(in[v]+1,out[v],x);//部分木(辺)
        //g(in[v],out[v],x);//部分木（頂点）
        //g(in[v],in[v]+1,x);//一点
        for(;;v=par[head[v]]){
            if(in[u]>in[v]) swap(u,v);
            if(head[u]==head[v]) break;
            g(in[head[v]],in[v]+1,x);
        }
        g(in[u],in[v]+1,x);
    }

    /*ex)
        ll ans=0;
        hld.query(u,v,[&](int a,int b){
            ans+=seg.getSum(a,b);
        },true);
    */
    template<class F>
    pair<State,State> query(int u,int v,const F &f,bool isedge){
        State l,r;
        for(;;v=par[head[v]]){
            if(in[u]>in[v]){
                swap(u,v);
                swap(l,r);
            }
            if(head[u]==head[v]) break;
            r=merge(f(in[head[v]],in[v]+1),r);
        }
        if(isedge&&u==v) return mkp(l,r);
        r=merge(f(in[u]+isedge,in[v]+1),r);
        return mkp(l,r);
    }
};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  int N,Q;
  cin>>N>>Q;
  vector<ll> W(N);
  rep(i,N) cin>>W[i];
  vector<vector<Edge>> g(N);
  rep(i,N-1){
      int a,b;
      cin>>a>>b;
      a--;b--;
      g[a].push_back(b);
      g[b].push_back(a);
  }
  
  HeavyLightDecomposition hld(N,g);

  vector<ll> v(N,0);
  rep(i,N) v[hld.in[i]]=W[i];
  LazySegmentTree seg(v);

  rep(q,Q){
      int t,a,b,c;
      cin>>t>>a>>b>>c;
      a--;b--;
      
      if(t==1){
          hld.update(a,b,c,[&](int a,int b,ll x){
              seg.update(a,b,x);
          });
      }else{
          State l,r;
          tie(l,r)=hld.query(a,b,[&](int a,int b){
              return seg.query(a,b);
          },false);
          swap(l.lef,l.rig);
          State res=merge(l,r);
          cout<<res.ans<<endl;
      }
  }

  return 0;
}



Measured memory_bytes: 71196