description: Chanek Jones is back, helping his long-lost relative Indiana Jones, to find a secret treasure in a maze buried below a desert full of illusions.
  
  The map of the labyrinth forms a tree with n rooms numbered from 1 to n and n - 1 tunnels connecting them such that it is possible to travel between each pair of rooms through several tunnels.
  
  The i-th room (1 ≤ i ≤ n) has a_i illusion rate. To go from the x-th room to the y-th room, there must exist a tunnel between x and y, and it takes max(|a_x + a_y|, |a_x - a_y|) energy. |z| denotes the absolute value of z.
  
  To prevent grave robbers, the maze can change the illusion rate of any room in it. Chanek and Indiana would ask q queries.
  
  There are two types of queries to be done:
  
    * 1\ u\ c — The illusion rate of the x-th room is changed to c (1 ≤ u ≤ n, 0 ≤ |c| ≤ 10^9). 
    * 2\ u\ v — Chanek and Indiana ask you the minimum sum of energy needed to take the secret treasure at room v if they are initially at room u (1 ≤ u, v ≤ n). 
  
  
  
  Help them, so you can get a portion of the treasure!
  
  Input
  
  The first line contains two integers n and q (2 ≤ n ≤ 10^5, 1 ≤ q ≤ 10^5) — the number of rooms in the maze and the number of queries.
  
  The second line contains n integers a_1, a_2, …, a_n (0 ≤ |a_i| ≤ 10^9) — inital illusion rate of each room.
  
  The i-th of the next n-1 lines contains two integers s_i and t_i (1 ≤ s_i, t_i ≤ n), meaning there is a tunnel connecting s_i-th room and t_i-th room. The given edges form a tree.
  
  The next q lines contain the query as described. The given queries are valid.
  
  Output
  
  For each type 2 query, output a line containing an integer — the minimum sum of energy needed for Chanek and Indiana to take the secret treasure.
  
  Example
  
  Input
  
  
  6 4
  10 -9 2 -1 4 -6
  1 5
  5 4
  5 6
  6 2
  6 3
  2 1 2
  1 1 -3
  2 1 2
  2 3 3
  
  
  Output
  
  
  39
  32
  0
  
  Note
  
  <image>
  
  In the first query, their movement from the 1-st to the 2-nd room is as follows.
  
    * 1 → 5 — takes max(|10 + 4|, |10 - 4|) = 14 energy. 
    * 5 → 6 — takes max(|4 + (-6)|, |4 - (-6)|) = 10 energy. 
    * 6 → 2 — takes max(|-6 + (-9)|, |-6 - (-9)|) = 15 energy. 
  
  In total, it takes 39 energy.
  
  In the second query, the illusion rate of the 1-st room changes from 10 to -3.
  
  In the third query, their movement from the 1-st to the 2-nd room is as follows.
  
    * 1 → 5 — takes max(|-3 + 4|, |-3 - 4|) = 7 energy. 
    * 5 → 6 — takes max(|4 + (-6)|, |4 - (-6)|) = 10 energy. 
    * 6 → 2 — takes max(|-6 + (-9)|, |-6 - (-9)|) = 15 energy. 
  
  
  
  Now, it takes 32 energy.
solution: #include <bits/stdc++.h>
  using namespace std;
  using ll = long long;
  constexpr int INF = 0x3f3f3f3f;
  constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
  constexpr double EPS = 1e-8;
  constexpr int MOD = 1000000007;
  constexpr int DY[]{1, 0, -1, 0}, DX[]{0, -1, 0, 1};
  constexpr int DY8[]{1, 1, 0, -1, -1, -1, 0, 1},
      DX8[]{0, -1, -1, -1, 0, 1, 1, 1};
  template <typename T, typename U>
  inline bool chmax(T &a, U b) {
    return a < b ? (a = b, true) : false;
  }
  template <typename T, typename U>
  inline bool chmin(T &a, U b) {
    return a > b ? (a = b, true) : false;
  }
  struct IOSetup {
    IOSetup() {
      std::cin.tie(nullptr);
      std::ios_base::sync_with_stdio(false);
      std::cout << fixed << setprecision(20);
    }
  } iosetup;
  struct HeavyLightDecomposition {
    std::vector<int> parent, subtree, id, inv, head;
    HeavyLightDecomposition(const std::vector<std::vector<int>> &graph,
                            int root = 0)
        : graph(graph) {
      int n = graph.size();
      parent.assign(n, -1);
      subtree.assign(n, 1);
      id.resize(n);
      inv.resize(n);
      head.resize(n);
      dfs1(root);
      head[root] = root;
      int now_id = 0;
      dfs2(root, now_id);
    }
    template <typename Fn>
    void v_update(int u, int v, Fn f) const {
      while (true) {
        if (id[u] > id[v]) std::swap(u, v);
        f(std::max(id[head[v]], id[u]), id[v] + 1);
        if (head[u] == head[v]) return;
        v = parent[head[v]];
      }
    }
    template <typename T, typename F, typename G>
    T v_query(int u, int v, F f, G g, const T ID) const {
      T left = ID, right = ID;
      while (true) {
        if (id[u] > id[v]) {
          std::swap(u, v);
          std::swap(left, right);
        }
        left = g(left, f(std::max(id[head[v]], id[u]), id[v] + 1));
        if (head[u] == head[v]) break;
        v = parent[head[v]];
      }
      return g(left, right);
    }
    template <typename Fn>
    void subtree_v_update(int ver, Fn f) const {
      f(id[ver], id[ver] + subtree[ver]);
    }
    template <typename T, typename Fn>
    T subtree_v_query(int ver, Fn f) const {
      return f(id[ver], id[ver] + subtree[ver]);
    }
    template <typename Fn>
    void e_update(int u, int v, Fn f) const {
      while (true) {
        if (id[u] > id[v]) std::swap(u, v);
        if (head[u] == head[v]) {
          f(id[u], id[v]);
          break;
        } else {
          f(id[head[v]] - 1, id[v]);
          v = parent[head[v]];
        }
      }
    }
    template <typename T, typename F, typename G>
    T e_query(int u, int v, F f, G g, const T ID) const {
      T left = ID, right = ID;
      while (true) {
        if (id[u] > id[v]) {
          std::swap(u, v);
          std::swap(left, right);
        }
        if (head[u] == head[v]) {
          left = g(left, f(id[u], id[v]));
          break;
        } else {
          left = g(left, f(id[head[v]] - 1, id[v]));
          v = parent[head[v]];
        }
      }
      return g(left, right);
    }
    template <typename Fn>
    void subtree_e_update(int ver, Fn f) const {
      f(id[ver], id[ver] + subtree[ver] - 1);
    }
    template <typename T, typename Fn>
    T subtree_e_query(int ver, Fn f) const {
      return f(id[ver], id[ver] + subtree[ver] - 1);
    }
    int lowest_common_ancestor(int u, int v) const {
      while (true) {
        if (id[u] > id[v]) std::swap(u, v);
        if (head[u] == head[v]) return u;
        v = parent[head[v]];
      }
    }
  
   private:
    std::vector<std::vector<int>> graph;
    void dfs1(int ver) {
      for (int &e : graph[ver]) {
        if (e != parent[ver]) {
          parent[e] = ver;
          dfs1(e);
          subtree[ver] += subtree[e];
          if (subtree[e] > subtree[graph[ver].front()])
            std::swap(e, graph[ver].front());
        }
      }
    }
    void dfs2(int ver, int &now_id) {
      id[ver] = now_id++;
      inv[id[ver]] = ver;
      for (int e : graph[ver]) {
        if (e != parent[ver]) {
          head[e] = (e == graph[ver].front() ? head[ver] : e);
          dfs2(e, now_id);
        }
      }
    }
  };
  template <typename Abelian>
  struct FenwickTree {
    FenwickTree(int n, const Abelian ID = 0) : n(n), ID(ID), dat(n, ID) {}
    void add(int idx, Abelian val) {
      while (idx < n) {
        dat[idx] += val;
        idx |= idx + 1;
      }
    }
    Abelian sum(int idx) const {
      Abelian res = ID;
      --idx;
      while (idx >= 0) {
        res += dat[idx];
        idx = (idx & (idx + 1)) - 1;
      }
      return res;
    }
    Abelian sum(int left, int right) const {
      return left < right ? sum(right) - sum(left) : ID;
    }
    Abelian operator[](const int idx) const { return sum(idx, idx + 1); }
    int lower_bound(Abelian val) const {
      if (val <= ID) return 0;
      int res = 0, exponent = 1;
      while (exponent <= n) exponent <<= 1;
      for (int mask = exponent >> 1; mask > 0; mask >>= 1) {
        if (res + mask - 1 < n && dat[res + mask - 1] < val) {
          val -= dat[res + mask - 1];
          res += mask;
        }
      }
      return res;
    }
  
   private:
    int n;
    const Abelian ID;
    std::vector<Abelian> dat;
  };
  int main() {
    int n, q;
    cin >> n >> q;
    vector<int> a(n);
    for (int i = (0); i < (n); ++i) cin >> a[i];
    vector<vector<int>> graph(n);
    for (int _ = (0); _ < (n - 1); ++_) {
      int s, t;
      cin >> s >> t;
      --s;
      --t;
      graph[s].emplace_back(t);
      graph[t].emplace_back(s);
    }
    HeavyLightDecomposition hld(graph);
    FenwickTree<ll> bit(n);
    for (int i = (0); i < (n); ++i) bit.add(hld.id[i], abs(a[i]));
    while (q--) {
      int type, u;
      cin >> type >> u;
      --u;
      if (type == 1) {
        int c;
        cin >> c;
        bit.add(hld.id[u], -abs(a[u]));
        a[u] = c;
        bit.add(hld.id[u], abs(a[u]));
      } else if (type == 2) {
        int v;
        cin >> v;
        --v;
        ll ans = hld.v_query(
            u, v, [&](int l, int r) -> ll { return bit.sum(l, r); },
            [](ll a, ll b) -> ll { return a + b; }, 0LL);
        ans *= 2;
        ans -= abs(a[u]);
        ans -= abs(a[v]);
        cout << ans << '\n';
      }
    }
  }
  