#include <bits/stdc++.h>
using namespace std;

template <class T> struct tree {
  struct edge {
    int u, v;
    T w;
  };
  const int n;
  vector<edge> es;
  vector<vector<int>> g;
  vector<int> pv, pe, sz, dep, vs, in, out, head;
  vector<T> dist;
  tree(int _n = 0) : n(_n), g(n) {}
  void add_edge(int u, int v, T w = 1) {
    g[u].push_back(es.size()), g[v].push_back(es.size());
    es.push_back({u, v, w});
  }
  int other(int id, int v) { return es[id].u ^ es[id].v ^ v; }
  void dfs(int v) {
    sz[v] = 1;
    for (int& id : g[v]) {
      if (id == pe[v]) continue;
      int to = other(id, v);
      assert(pv[to] == -1);
      pv[to] = v, pe[to] = id;
      dep[to] = dep[v] + 1, dist[to] = dist[v] + es[id].w;
      dfs(to);
      sz[v] += sz[to];
      if (g[v][0] == pv[v] or sz[to] > sz[other(g[v][0], v)]) swap(g[v][0], id);
    }
  }
  void build(int r = 0) {
    assert((int)es.size() == n - 1);
    pv.assign(n, -1), pe.resize(n), sz.resize(n), dep.resize(n), dist.resize(n);
    pe[r] = -1, dep[r] = 0, dist[r] = 0;
    dfs(r);
  }
  void dfs_hld(int v) {
    in[v] = vs.size(), vs.push_back(v);
    for (int id : g[v]) {
      if (id == pe[v]) continue;
      int to = other(id, v);
      head[to] = to == other(g[v][0], v) ? head[v] : to;
      dfs_hld(to);
    }
    out[v] = vs.size();
  }
  void build_hld(int r = 0) {
    build(r);
    vs.clear(), in.resize(n), out.resize(n), head.resize(n);
    head[r] = r;
    dfs_hld(r);
  }
  bool anc(int u, int v) const { return in[u] <= in[v] and out[v] <= out[u]; }
  int lca(int u, int v) const {
    while (true) {
      if (in[u] > in[v]) swap(u, v);
      if (head[u] == head[v]) return u;
      v = pv[head[v]];
    }
  }
  int la(int v, int d) const {
    assert(0 <= d and d <= dep[v]);
    while (dep[head[v]] > d) v = pv[head[v]];
    return vs[in[head[v]] + (d - dep[head[v]])];
  }
  int next(int from, int to) const {
    assert(from != to);
    if (not anc(from, to)) return pv[from];
    return la(to, dep[from] + 1);
  }
  vector<pair<int, int>> ascend(int from, int to) const {
    assert(anc(to, from));
    vector<pair<int, int>> res;
    while (head[from] != head[to]) {
      res.emplace_back(in[from], in[head[from]]);
      from = pv[head[from]];
    }
    if (from != to) res.emplace_back(in[from], in[to] + 1);
    return res;
  }
  vector<pair<int, int>> descend(int from, int to) const {
    assert(anc(from, to));
    if (from == to) return {};
    if (head[from] == head[to]) return {{in[from] + 1, in[to]}};
    auto res = descend(from, pv[head[to]]);
    res.emplace_back(in[head[to]], in[to]);
    return res;
  }
  template <class F> void run(int from, int to, F f, bool vertex = true) const {
    int v = lca(from, to);
    for (auto e : ascend(from, v)) f(e.first + 1, e.second);
    if (vertex) f(in[v], in[v] + 1);
    for (auto e : descend(v, to)) f(e.first, e.second + 1);
  }
};

template <class T, class F, class Op = function<T(T, T)>,
          class Apply = function<T(T, F)>, class Compose = function<F(F, F)>>
struct lazy_segtree {
  const Op op;
  const T e = T();
  const Apply ap;
  const Compose cp;
  const F id = F();
  const int n = 0;
  vector<T> t;
  vector<F> d;
  T& operator[](int i) { return t[n + i]; }
  void build() { for (int i = n; i--; ) t[i] = op(t[2 * i], t[2 * i + 1]); }
  void push() { for (int i = 0; i < n; ++i) push(i); }
  void apply(int i, F f) {
    t[i] = ap(t[i], f);
    if (i < n) d[i] = cp(d[i], f);
  }
  void push(int i) {
    apply(2 * i, d[i]), apply(2 * i + 1, d[i]);
    d[i] = id;
  }
  void propagate(int i) {
    for (int h = __lg(i), tz = __builtin_ctz(i); h > tz; --h) push(i >> h);
  }
  T fold(int l, int r) {
    propagate(l += n), propagate(r += n);
    T a = e, b = e;
    for (; l < r; l >>= 1, r >>= 1) {
      if (l & 1) a = op(a, t[l++]);
      if (r & 1) b = op(t[--r], b);
    }
    return op(a, b);
  }
  T get(int i) { return fold(i, i + 1); }
  void act(int l, int r, F f) {
    propagate(l += n), propagate(r += n);
    for (int i = l, j = r; i < j; i >>= 1, j >>= 1) {
      if (i & 1) apply(i++, f);
      if (j & 1) apply(--j, f);
    }
    l = l >> __builtin_ctz(l);
    while (l >>= 1) t[l] = op(t[2 * l], t[2 * l + 1]);
    r = r >> __builtin_ctz(r);
    while (r >>= 1) t[r] = op(t[2 * r], t[2 * r + 1]);
  }
  void set(int i, T a) {
    propagate(i += n), propagate(i + 1);
    t[i] = a;
    while (i >>= 1) t[i] = op(t[2 * i], t[2 * i + 1]);
  }
};
template <class T, class F, class Op, class Apply, class Compose>
auto make_lazy_segtree(int n, Op op, T e, Apply ap, Compose cp, F id) {
  return lazy_segtree<T, F, Op, Apply, Compose>{
    op, e, ap, cp, id, n, vector<T>(2 * n, e), vector<F>(n, id)
  };
}

constexpr int inf = numeric_limits<int>::max();

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, q;
  cin >> n >> q;
  vector<int> w(n);
  for (auto&& e : w) {
    cin >> e;
  }
  tree<int> g(n);
  for (int id = 0; id < n - 1; ++id) {
    int u, v;
    cin >> u >> v;
    --u, --v;
    g.add_edge(u, v);
  }
  g.build_hld();
  struct node {
    int v, l, r, sum, len;
    node() {}
    node(int x) : v(x), l(x), r(x), sum(x), len(1) {}
    node operator*(const node& b) const {
      if (len == 0) {
        return b;
      }
      if (b.len == 0) {
        return *this;
      }
      node c;
      c.v = max({v, b.v, r + b.l});
      c.l = max(l, sum + b.l);
      c.r = max(r + b.sum, b.r);
      c.sum = sum + b.sum;
      c.len = len + b.len;
      return c;
    }
  };
  node e(0);
  e.len = 0;
  auto apply = [](node a, int f) {
    if (f == inf) {
      return a;
    }
    a.v = f < 0 ? f : f * a.len;
    a.l = a.r = a.v;
    a.sum = f * a.len;
    return a;
  };
  auto st = make_lazy_segtree<pair<node, node>>(n, [](const auto& a, const auto& b) {
    return make_pair(a.first * b.first, b.second * a.second);
  }, {e, e}, [&](const auto& p, int f) {
    return make_pair(apply(p.first, f), apply(p.second, f));
  }, [](int f, int g) {
    return g != inf ? g : f;
  }, inf);
  for (int v = 0; v < n; ++v) {
    st[g.in[v]] = {node(w[v]), node(w[v])};
  }
  st.build();
  while (q--) {
    int t, u, v, c;
    cin >> t >> u >> v >> c;
    --u, --v;
    if (t == 1) {
      g.run(u, v, [&](int l, int r) {
        if (l > r) {
          swap(l, r);
        }
        st.act(l, r, c);
      });
    } else {
      node a = e;
      g.run(u, v, [&](int l, int r) {
        if (l < r) {
          a = a * st.fold(l, r).first;
        } else {
          a = a * st.fold(r, l).second;
        }
      });
      cout << a.v << '\n';
    }
  }
}



Measured memory_bytes: 49168