#include<bits/stdc++.h>

using namespace std;

typedef long long int64;
const int64 INF = 1LL << 55;

struct CentroidPathDecomposition
{
  struct Centroid
  {
    int ParIndex, ParDepth, Deep;
    vector< int > node;

    inline int size()
    {
      return (node.size());
    }

    inline int &operator[](int k)
    {
      return (node[k]);
    }

    inline pair< int, int > Up()
    {
      return (make_pair(ParIndex, ParDepth));
    }
  };

  vector< vector< int > > graph;
  vector< int > SubTreeSize, NextPath;
  vector< int > TreeIndex, TreeDepth;
  vector< Centroid > Centroids;

  void BuildSubTreeSize()
  {
    stack< pair< int, int > > s;
    s.emplace(0, -1);
    while(!s.empty()) {
      auto p = s.top();
      s.pop();
      if(~SubTreeSize[p.first]) {
        NextPath[p.first] = -1;
        for(auto &to : graph[p.first]) {
          if(p.second == to) continue;
          SubTreeSize[p.first] += SubTreeSize[to];
          if(NextPath[p.first] == -1 || SubTreeSize[NextPath[p.first]] < SubTreeSize[to]) {
            NextPath[p.first] = to;
          }
        }
      } else {
        s.push(p);
        SubTreeSize[p.first] = 1;
        for(auto &to : graph[p.first]) {
          if(p.second != to) s.emplace(to, p.first);
        }
      }
    }
  }

  void BuildPath()
  {
    stack< pair< int, int > > s;
    Centroids.push_back((Centroid) {-1, -1, 0});
    s.push({0, -1});
    TreeIndex[0] = 0;
    while(!s.empty()) {
      auto p = s.top();
      s.pop();
      TreeDepth[p.first] = Centroids[TreeIndex[p.first]].size();
      for(auto &to : graph[p.first]) {
        if(p.second != to) {
          if(to == NextPath[p.first]) { // Centroid-Path
            TreeIndex[to] = TreeIndex[p.first];
          } else {                  // Not Centroid-Path
            TreeIndex[to] = Centroids.size();
            Centroids.push_back((Centroid) {TreeIndex[p.first], TreeDepth[p.first], Centroids[TreeIndex[p.first]].Deep + 1});
          }
          s.emplace(to, p.first);
        }
      }
      Centroids[TreeIndex[p.first]].node.push_back(p.first);
    }
  }

  void AddEdge(int x, int y)
  {
    graph[x].push_back(y);
    graph[y].push_back(x);
  }

  void Build()
  {
    BuildSubTreeSize();
    BuildPath();
  }

  inline int size()
  {
    return (Centroids.size());
  }

  inline pair< int, int > Information(int idx)
  {
    return (make_pair(TreeIndex[idx], TreeDepth[idx]));
  }

  inline Centroid &operator[](int k)
  {
    return (Centroids[k]);
  }

  inline int LCA(int a, int b) // ??????????????¨??????
  {
    int TreeIdxA, TreeDepthA, TreeIdxB, TreeDepthB;
    tie(TreeIdxA, TreeDepthA) = Information(a);
    tie(TreeIdxB, TreeDepthB) = Information(b);
    while(TreeIdxA != TreeIdxB) {
      if(Centroids[TreeIdxA].Deep > Centroids[TreeIdxB].Deep) {
        tie(TreeIdxA, TreeDepthA) = Centroids[TreeIdxA].Up();
      } else {
        tie(TreeIdxB, TreeDepthB) = Centroids[TreeIdxB].Up();
      }
    }
    if(TreeDepthA > TreeDepthB) swap(TreeDepthA, TreeDepthB);
    return (Centroids[TreeIdxA][TreeDepthA]);
  }

  CentroidPathDecomposition(int SZ)
  {
    graph.resize(SZ);
    SubTreeSize.assign(SZ, -1);
    NextPath.resize(SZ);
    TreeIndex.resize(SZ);
    TreeDepth.resize(SZ);
  }

  void AddPath(int a, int b, int c);

  int64 QueryPath(int a, int b);
};


struct State
{
  int64 ans, all, left, right;

  State() : ans(-INF), all(0), left(-INF), right(-INF) {}

  State(int64 val, int length)
  {
    all = val * length;
    ans = left = right = (val > 0 ? all : val);
  }

  State operator+(State s) const
  {
    State ret;
    ret.ans = max({ans, s.ans, right + s.left});
    ret.all = all + s.all;
    ret.left = max(left, all + s.left);
    ret.right = max(s.right, right + s.all);
    return (ret);
  }
};


struct SegmentTree
{
  vector< State > seg;
  vector< int64 > lazy;
  int sz;

  SegmentTree(int n)
  {
    sz = 1;
    while(sz < n) sz <<= 1;
    seg.assign(2 * sz - 1, State());
    lazy.assign(2 * sz - 1, INF);
  }

  inline void push(int k, int l, int r)
  {
    if(lazy[k] == INF) return;
    seg[k] = State(lazy[k], r - l);
    if(k < sz - 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)
  {
    push(k, l, r);
    if(a >= r || b <= l) {
      return;
    }
    if(a <= l && r <= b) {
      lazy[k] = x;
      push(k, l, r);
      return;
    }
    update(a, b, x, 2 * k + 1, l, (l + r) >> 1);
    update(a, b, x, 2 * k + 2, (l + r) >> 1, r);
    seg[k] = seg[2 * k + 1] + seg[2 * k + 2];
  }

  State query(int a, int b, int k, int l, int r)
  {
    push(k, l, r);
    if(a >= r || b <= l) return (State());
    if(a <= l && r <= b) return (seg[k]);
    return (query(a, b, 2 * k + 1, l, (l + r) >> 1) +
            query(a, b, 2 * k + 2, (l + r) >> 1, r));
  }

  void update(int a, int b, int x)
  {
    update(a, b, x, 0, 0, sz);
  }

  State query(int a, int b)
  {
    return (query(a, b, 0, 0, sz));
  }

  void set(int k, int v)
  {
    seg[k + sz - 1] = State(v, 1);
  }

  void build()
  {
    for(int k = sz - 2; k >= 0; k--) {
      seg[k] = seg[2 * k + 1] + seg[2 * k + 2];
    }
  }

};


int N, Q, S[200000];
vector< SegmentTree > segs;

void CentroidPathDecomposition::AddPath(int a, int b, int c)
{
  int TreeIdxA, TreeDepthA, TreeIdxB, TreeDepthB;
  tie(TreeIdxA, TreeDepthA) = Information(a);
  tie(TreeIdxB, TreeDepthB) = Information(b);
  while(TreeIdxA != TreeIdxB) {
    if(Centroids[TreeIdxA].Deep > Centroids[TreeIdxB].Deep) {
      segs[TreeIdxA].update(0, TreeDepthA + 1, c);
      tie(TreeIdxA, TreeDepthA) = Centroids[TreeIdxA].Up();
    } else {
      segs[TreeIdxB].update(0, TreeDepthB + 1, c);
      tie(TreeIdxB, TreeDepthB) = Centroids[TreeIdxB].Up();
    }
  }
  if(TreeDepthA > TreeDepthB) swap(TreeDepthA, TreeDepthB);
  segs[TreeIdxA].update(TreeDepthA, TreeDepthB + 1, c);
}

int64 CentroidPathDecomposition::QueryPath(int a, int b)
{
  int TreeIdxA, TreeDepthA, TreeIdxB, TreeDepthB;
  tie(TreeIdxA, TreeDepthA) = Information(a);
  tie(TreeIdxB, TreeDepthB) = Information(b);

  State left, right;
  while(TreeIdxA != TreeIdxB) {
    if(Centroids[TreeIdxA].Deep > Centroids[TreeIdxB].Deep) {
      left = segs[TreeIdxA].query(0, TreeDepthA + 1) + left;
      tie(TreeIdxA, TreeDepthA) = Centroids[TreeIdxA].Up();
    } else {
      right = segs[TreeIdxB].query(0, TreeDepthB + 1) + right;
      tie(TreeIdxB, TreeDepthB) = Centroids[TreeIdxB].Up();
    }
  }
  if(TreeDepthA > TreeDepthB) {
    swap(right.left, right.right);
    right = right + segs[TreeIdxA].query(TreeDepthB, TreeDepthA + 1);
    right = right + left;
    return (right.ans);
  } else {
    swap(left.left, left.right);
    left = left + segs[TreeIdxA].query(TreeDepthA, TreeDepthB + 1);
    left = left + right;
    return (left.ans);
  }
}

int main()
{
  scanf("%d %d", &N, &Q);
  for(int i = 0; i < N; i++) {
    scanf("%d", &S[i]);
  }

  CentroidPathDecomposition tree(N);
  for(int i = 0; i < N - 1; i++) {
    int U, V;
    scanf("%d %d", &U, &V);
    tree.AddEdge(--U, --V);
  }

  tree.Build();
  for(int i = 0; i < tree.size(); i++) {
    segs.push_back(SegmentTree(tree[i].size()));
    for(int j = 0; j < tree[i].size(); j++) {
      segs[i].set(j, S[tree[i][j]]);
    }
    segs[i].build();
  }

  while(Q--) {
    int T, A, B, C;
    scanf("%d %d %d %d", &T, &A, &B, &C);
    --A, --B;
    if(T == 1) tree.AddPath(A, B, C);
    else printf("%lld\n", tree.QueryPath(A, B));
  }
}

Measured memory_bytes: 59104