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;
  void read(int& x) { scanf("%d", &x); }
  void read(long long& x) { scanf("%lld", &x); }
  void read(double& x) { scanf("%lf", &x); }
  long long gcd(long long x, long long y) {
    while (y) {
      long long t = x % y;
      x = y;
      y = t;
    }
    return x;
  }
  void update(vector<long long>& b, int sp, int x, long long val) {
    x += sp;
    b[x] = val;
    x >>= 1;
    while (x >= 1) {
      b[x] = b[x << 1] + b[(x << 1) + 1];
      x >>= 1;
    }
  }
  long long query(vector<long long>& b, int sp, int s, int e) {
    s += sp;
    e += sp;
    long long ret = 0;
    while (s <= e) {
      if (s == e) {
        ret += b[s];
        break;
      }
      if (s & 1) {
        ret += b[s];
        s = (s + 1) >> 1;
      } else
        s >>= 1;
      if (e & 1)
        e >>= 1;
      else {
        ret += b[e];
        e = (e - 1) >> 1;
      }
    }
    return ret;
  }
  int lca(int u, int v, vector<vector<int>>& pars, vector<int>& h) {
    int d = h[v] - h[u];
    for (int k = 0; d; k++, d >>= 1) {
      if (d & 1) v = pars[v][k];
    }
    if (u == v) return u;
    for (int k = pars[u].size() - 1; k >= 0; k--) {
      if (k >= pars[u].size() || pars[u][k] == pars[v][k]) continue;
      u = pars[u][k];
      v = pars[v][k];
    }
    return pars[u][0];
  }
  void print_tree(int sp, vector<long long>& b) {
    for (int i = 1; i < (sp * 2); i++) {
      printf("%d ", b[i]);
      if ((i & (i + 1)) == 0) printf("\n");
    }
    printf("\n");
  }
  void solve() {
    int n, q;
    scanf("%d%d", &n, &q);
    vector<long long> a(n + 1);
    for (int i = 1; i <= n; i++) {
      scanf("%lld", &a[i]);
      if (a[i] < 0) a[i] = -a[i];
    }
    vector<vector<int>> adj(n + 1);
    for (int i = 1; i < n; i++) {
      int u, v;
      scanf("%d%d", &u, &v);
      adj[u].push_back(v);
      adj[v].push_back(u);
    }
    vector<int> h(n + 1, -1);
    vector<vector<int>> pars(n + 1);
    {
      vector<int> q;
      q.push_back(1);
      int hd = 0;
      h[1] = 0;
      while (hd < q.size()) {
        int u = q[hd++];
        if (pars[u].size()) {
          for (int k = 1; k - 1 < pars[pars[u][k - 1]].size(); k++) {
            pars[u].push_back(pars[pars[u][k - 1]][k - 1]);
          }
        }
        for (auto v : adj[u]) {
          if (h[v] != -1) continue;
          q.push_back(v);
          h[v] = h[u] + 1;
          pars[v].push_back(u);
        }
      }
    }
    vector<int> tour;
    vector<int> finds(n + 1), binds(n + 1);
    {
      stack<int> stk;
      stk.push(1);
      while (stk.size()) {
        int u = stk.top();
        stk.pop();
        tour.push_back(u);
        if (u < 0)
          binds[-u] = tour.size() - 1;
        else {
          finds[u] = tour.size() - 1;
          stk.push(-u);
          for (auto v : adj[u])
            if (h[v] == h[u] + 1) stk.push(v);
        }
      }
    }
    int m = tour.size();
    int sp = 1;
    while (sp < m) sp <<= 1;
    vector<long long> b(sp << 1);
    for (int i = 0; i < m; i++) {
      if (tour[i] < 0)
        b[sp + i] = -a[-tour[i]];
      else
        b[sp + i] = a[tour[i]];
    }
    for (int i = sp - 1; i >= 1; i--) {
      b[i] = b[i << 1] + b[(i << 1) + 1];
    }
    while (q--) {
      int t, u, v;
      scanf("%d%d%d", &t, &u, &v);
      if (t == 1) {
        a[u] = (long long)(abs(v));
        update(b, sp, finds[u], a[u]);
        update(b, sp, binds[u], -a[u]);
      } else {
        if (u == v) {
          printf("0\n");
          continue;
        }
        if (h[u] > h[v]) swap(u, v);
        int r = lca(u, v, pars, h);
        if (r == u) {
          long long val = query(b, sp, finds[u], finds[v]);
          printf("%lld\n", 2 * val - a[u] - a[v]);
        } else {
          long long val = query(b, sp, finds[r], finds[u]) +
                          query(b, sp, finds[r], finds[v]) - a[r];
          printf("%lld\n", 2 * val - a[u] - a[v]);
        }
      }
    }
  }
  int main() {
    solve();
    return 0;
  }
  