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;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

struct HLDT {
  vector< vector<int> > graph;
  // vid:????§£????????????????????????????????§?????£?¶????
  vector<int> vid, head, heavy, par, depth, inv;

  HLDT(){}
  HLDT(int n)
    :graph(n), vid(n, -1), head(n), heavy(n, -1), par(n), depth(n), inv(n){}

  void add_edge(int u, int v) {
    graph[u].push_back(v);
    graph[v].push_back(u);
  }

  void build() {
    dfs(0, -1);
    bfs();
  }

  int dfs(int u, int p) {
    par[u] = p;
    int subsz = 1, max_chsz = 0;
    for(int v : graph[u]) {
      if(v == p) continue;
      depth[v] = depth[u] + 1;
      int chsz = dfs(v, u);
      subsz += chsz;
      if(max_chsz < chsz) max_chsz = chsz, heavy[u] = v;
    }
    return subsz;
  }

  void bfs() {
    int id = 0;
    queue<int> que; // ????§£?????????????????????
    que.push(0);
    while(!que.empty()) {
      int h = que.front(); que.pop();
      for(int i = h; i != -1; i = heavy[i]) { // ????????????Heavy edge????????£?????????????????????
	vid[i] = id++;
	inv[vid[i]] = i;
	head[i] = h;
	for(int j : graph[i]) {
	  if(j != par[i] && j != heavy[i]) que.push(j);
	}
      }
    }
  }

  void for_each(int u, int v, vector< tuple<int, int, bool> >& lr) {
    if(vid[u] < vid[v]) {
      lr.emplace_back(max(vid[head[v]], vid[u]), vid[v], true); // ?????????
      if(head[u] != head[v]) for_each(u, par[head[v]], lr);
    } else { // ??????????????????????????§????????????????????§????????????????????????
      lr.emplace_back(max(vid[head[u]], vid[v]), vid[u], false); // ?????????
      if(head[u] != head[v]) for_each(par[head[u]], v, lr);
    }
  }

  int lca(int u, int v) {
    if(vid[u] > vid[v]) swap(u, v);
    if(head[u] == head[v]) return u;
    return lca(u, par[head[v]]);
  }

  int distance(int u, int v) {
    return depth[u] + depth[v] - 2*depth[lca(u, v)];
  }
};

struct State {
  int sum, mxs, lmxs, rmxs;
  State():sum(0), mxs(-inf), lmxs(-inf), rmxs(-inf){}
  State(int sum, int mxs, int lmxs, int rmxs)
    :sum(sum), mxs(mxs), lmxs(lmxs), rmxs(rmxs){}
  State(int c, int sz) {
    int d = (c > 0 ? c*sz : c);
    sum = c*sz, mxs = lmxs = rmxs = d;
  }
  State operator + (State s) {
    State res;
    res.sum = sum + s.sum;
    res.mxs = max(mxs, s.mxs, rmxs + s.lmxs);
    res.lmxs = max(lmxs, sum + s.lmxs);
    res.rmxs = max(rmxs + s.sum, s.rmxs);
    return res;
  }
  State operator ~ () {
    State res = *this;
    swap(res.lmxs, res.rmxs);
    return res;
  }
};

// Lazy-evaluated Segment Tree
struct SegmentTree
{
  vector<State> sum;
  vector<int> lazy;
  int sz;
  SegmentTree(){}
  SegmentTree(int n)
  {
    sz = 1; while(sz < n) sz *= 2;
    sum.resize(2*sz-1, State());
    lazy.resize(2*sz-1, -inf);
  }
  inline void lazy_evaluate(int k, int l, int r)
  {
    if(lazy[k] == -inf) return;
    sum[k] = State(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, int x, int k, int l, int r)
  {
    lazy_evaluate(k, l, r);
    if(r <= a || b <= l) return;
    if(a <= l && r <= b) {
      lazy[k] = x;
      lazy_evaluate(k, l, r);
      return;
    }
    update(a, b, x, 2*k+1, l, (l+r)/2);
    update(a, b, x, 2*k+2, (l+r)/2, r);
    sum[k] = sum[2*k+1] + sum[2*k+2];
  }
  void update(int a, int b, int x)
  {
    update(a, b, x, 0, 0, sz);
  }
  State query(int a, int b, int k, int l, int r)
  {
    lazy_evaluate(k, l, r);
    if(r <= a || b <= l) return State();
    if(a <= l && r <= b) return sum[k];
    return query(a, b, 2*k+1, l, (l+r)/2) + query(a, b, 2*k+2, (l+r)/2, r);
  }
  State query(int a, int b)
  {
    return query(a, b, 0, 0, sz);
  }
};

int n, q;
vector<int> w;
HLDT hldt;
SegmentTree seg;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  cin >> n >> q;
  w.resize(n);
  hldt = HLDT(n);
  seg = SegmentTree(n);
  rep(i, n) cin >> w[i];
  rep(i, n-1) {
    int s, e;
    cin >> s >> e;
    --s, --e;
    hldt.add_edge(s, e);
  }
  hldt.build();
  rep(i, n) {
    vector< tuple<int, int, bool> > lr;
    hldt.for_each(i, i, lr);
    for(auto p : lr) {
      int x, y; bool z;
      tie(x, y, z) = p;
      seg.update(x, y + 1, w[i]);
    }
  }

  rep(i, q) {
    int t, a, b, c;
    cin >> t >> a >> b >> c;
    --a, --b;
    vector< tuple<int, int, bool> > lr;
    hldt.for_each(a, b, lr);
    if(t == 1) {
      for(auto p : lr) {
	int x, y; bool z;
	tie(x, y, z) = p;
	seg.update(x, y + 1, c);
      }
    } else if(t == 2) {
      State ds, us;
      for(auto p : lr) {
	int x, y; bool z;
	tie(x, y, z) = p;
	if(z) ds = seg.query(x, y + 1) + ds;
	else us = seg.query(x, y + 1) + us;
      }
      cout << (~us + ds).mxs << endl;
    }
  }

  return 0;
}