#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <deque>
#include <complex>
#include <string>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <valarray>
#include <unordered_map>
#include <iterator>
#include <functional>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const ll INF = 1ll<<40;
const double EPS = 1e-8;
const int MOD = 1000000007;

struct handler{
	typedef struct vt{
		ll l, r, sum, ans;
		vt(ll l, ll r, ll sum, ll ans)
			:l(l), r(r), sum(sum), ans(ans){}
		vt(ll x=0){
			l=r=sum=ans=x;
		}
		friend ostream &operator<<(ostream &os, const vt &t){
			return os << "{" << t.l << ", " << t.r << ", " << t.sum << ", " << t.ans << "}";
		}
	} val_t;
	typedef ll opr_t;
	handler(){}
	static val_t def_val(){ return val_t(-INF); }
	static opr_t def_lazy(){ return INF; }
	static val_t resolve(const val_t &x, const opr_t &y, int l, int r){
		return y == INF ? x : 
				val_t(y <= 0 ? y : y * (r - l),
					 y <= 0 ? y : y * (r - l),
					 y * (r - l),
					 y <= 0 ? y : y * (r - l));
	}
	static opr_t push(const opr_t &x, const opr_t &y){
		return y == INF ? x : y;
	}
	static val_t merge(const val_t &l, const val_t &r){
		if(l.l == -INF) return r;
		if(r.l == -INF) return l;
/*		cout << "merge " << l << ", " << r << ": " << val_t(max(l.l, l.sum+r.l),
					 max(r.r, r.sum+l.r),
					 l.sum + r.sum,
					 max({l.ans, r.ans, l.r + r.l})) << endl;
*/		return val_t(max(l.l, l.sum+r.l),
					 max(r.r, r.sum+l.r),
					 max(-INF, l.sum + r.sum),
					 max({l.ans, r.ans, l.r + r.l}));
	}
};

template<typename Handler>
struct SegTreeLazy{
	typedef typename Handler::val_t val_t;
	typedef typename Handler::opr_t opr_t;
	vector<val_t> val;
	vector<opr_t> lazy;
	Handler hdl;
	int n;
	
	SegTreeLazy(int size):hdl(){
		n=1;
		while(n<size) n<<=1;
		val=vector<val_t>(2*n, hdl.def_val());
		lazy=vector<opr_t>(2*n, hdl.def_lazy());
	}
	
	SegTreeLazy(const vector<val_t> &in):hdl(){
		n=1;
		while(n<in.size()) n<<=1;
		val=vector<val_t>(2*n, hdl.def_val());
		lazy=vector<opr_t>(2*n, hdl.def_lazy());
		for(int i=n-1 + in.size()-1;i>=0;i--){
			if(n-1 <= i) val[i] = in[i - (n-1)];
			else val[i] = hdl.merge(val[i*2+1],val[i*2+2]);
		}
	}
	val_t update(int a,int b,opr_t x, int k,int l,int r){
		if(r<=a||b<=l) return hdl.resolve(val[k], lazy[k], l, r);
		if(a<=l&&r<=b){
			lazy[k] = hdl.push(lazy[k], x);
			return hdl.resolve(val[k], lazy[k], l, r);
		}
		lazy[k*2+1] = hdl.push(lazy[k*2+1], lazy[k]);
		lazy[k*2+2] = hdl.push(lazy[k*2+2], lazy[k]);
		lazy[k] = hdl.def_lazy();
		return val[k] = hdl.merge(update(a, b, x, k*2+1, l, (l+r)/2),
								  update(a, b, x, k*2+2, (l+r)/2, r));
	}
	val_t query(int a,int b,int k,int l,int r){
		if(r<=a||b<=l) return hdl.def_val();
		if(a<=l&&r<=b) return hdl.resolve(val[k], lazy[k], l, r);
		val[k] = hdl.resolve(val[k], lazy[k], l, r);
		lazy[k*2+1] = hdl.push(lazy[k*2+1], lazy[k]);
		lazy[k*2+2] = hdl.push(lazy[k*2+2], lazy[k]);
		lazy[k] = hdl.def_lazy();
		return hdl.merge(query(a, b, k*2+1, l, (l+r)/2),
						 query(a, b, k*2+2, (l+r)/2, r));
	}
	val_t update(int a, int b, opr_t x){return update(a, b, x, 0, 0, n);}
	val_t query(int a, int b){return query(a, b, 0, 0, n);}
	val_t operator[](size_t i){return query(i, i+1);}
	friend ostream& operator<<(ostream &os, SegTreeLazy<Handler> &t){
		REP(i, t.n) os << (i ? ", " : "[") << t.query(i, i+1);
		return os << "]";
	}
};

template<class Handler, class SegTree>
struct HLDecomp{
	typedef typename Handler::val_t val_t;
	typedef typename Handler::opr_t opr_t;
	struct NodeInfo{
		int idx, pos, cnt, par, heavy, depth;
	};
	int n;
	vector<NodeInfo> node;
	vector<SegTree> seg;	// even: down
							// odd : up
	vector<vi> e;
	HLDecomp(const vector<vi> &g, const vector<val_t> &val, int root = 0)
		:n(g.size()), node(n){
		stack<int> st;
		st.push(root);
		node[root].depth = 0;
		node[root].par = -1;
		while(!st.empty()){
			int v = st.top(); st.pop();
			if(v<0){
				v = ~v;
				if(v != root) node[node[v].par].cnt += node[v].cnt;
				node[v].heavy = -1;
				int mc = 0;
				FOR(u, g[v])if(*u!=node[v].par){
					if(chmax(mc, node[*u].cnt)) node[v].heavy = *u;
				}
			}else{
				node[v].cnt = 1;
				st.push(~v);
				FOR(u, g[v])if(*u!=node[v].par){
					node[*u].par = v;
					node[*u].depth = node[v].depth+1;
					st.push(*u);
				}
			}
		}
		st.push(root);
		while(!st.empty()){
			vector<val_t> w;
			vi d;
			int v = st.top();st.pop();
			int p = node[v].par;
			for(;v>=0;v=node[v].heavy){
				FOR(u, g[v])if(*u!=node[v].par && *u!=node[v].heavy) st.push(*u);
				node[v].idx = seg.size();
				node[v].pos = w.size();
				node[v].par = p;
				w.pb(val[v]);
				d.pb(v);
			}
//			cout << "heavy: " << d << endl;
			seg.eb(w);
			e.pb(d);
			reverse(ALL(w));
			reverse(ALL(d));
			seg.eb(w);
			e.pb(d);
		}
	}
	struct Path{
		int idx, s, t;
		Path(int idx, int s, int t):idx(idx), s(s), t(t){}
	};
	vector<Path> path(int u, int v, int leq=0){
		val_t vu = Handler::def_val();
		val_t vv = Handler::def_val();
		vector<Path> res, rev;
		while(node[u].idx!=node[v].idx){
//			cout << u+1 << ", " << v+1 << endl;
			int pu = node[u].par;
			int pv = node[v].par;
			if((pu==-1 ? -1 : node[pu].depth) > (pv == -1 ? -1 : node[pv].depth)){
				res.eb(node[u].idx+1, e[node[u].idx].size() - 1 - node[u].pos, e[node[u].idx].size());
				u = node[u].par;
			}else{
				rev.eb(node[v].idx  ,0 ,node[v].pos+1);
				v = node[v].par;
			}
		}
		if(node[u].pos < node[v].pos+leq){
			res.eb(node[u].idx, node[u].pos, node[v].pos+1);
		}else{
			res.eb(node[u].idx+1, e[node[u].idx].size() - 1 - node[u].pos, e[node[u].idx].size() - node[v].pos);
		}
		res.insert(res.end(), RALL(rev));
		return res;
	}
	
	void update(int u, int v, opr_t x){
		auto paths = path(u, v);
		FOR(p, paths){
//			cout << "!" << p->idx << ", " << p->s << ", " << p->t << ": " << x << endl;
			seg[p->idx].update(p->s, p->t, x);
//			cout << seg[p->idx] << endl;
		}
		paths = path(v, u, 1);
		FOR(p, paths){
//			cout << "!" << p->idx << ", " << p->s << ", " << p->t << ": " << x << endl;
			seg[p->idx].update(p->s, p->t, x);
		}
	}
	val_t query(int u, int v){
		val_t res = Handler::def_val();
		auto paths = path(u, v);
		FOR(p, paths){
//			cout << p->idx << ", " << p->s << ", " << p->t << ": " << seg[p->idx].query(p->s, p->t) << endl;
			res = Handler::merge(res, seg[p->idx].query(p->s, p->t));
		}
		return res;
	}
};

int n, m;

int main(int argc, char *argv[]){
	scanf("%d%d", &n, &m);
	vector<handler::val_t> w;
	REP(i, n){
		int x;
		scanf("%d", &x);
		w.eb(x);
	}
	vector<vi> g(n);
	REP(i, n-1){
		int u, v;
		scanf("%d%d", &u, &v); u--; v--;
		g[u].pb(v);g[v].pb(u);
	}
	HLDecomp<handler, SegTreeLazy<handler>> hldc(g, w);
	REP(i, m){
		int t, a, b, c;
		scanf("%d%d%d%d", &t, &a, &b, &c); a--; b--;
		if(t==1){
				hldc.update(a, b, c);
		}else{
				printf("%d\n", hldc.query(a, b).ans);
		}
	}
	return 0;
}

Measured memory_bytes: 114148