#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
template <typename A>
ostream& operator<<(ostream& cout, vector<A> const& v);
template <typename A, typename B>
ostream& operator<<(ostream& cout, pair<A, B> const& p) {
  return cout << "(" << p.first << ", " << p.second << ")";
}
template <typename A>
ostream& operator<<(ostream& cout, vector<A> const& v) {
  cout << "[";
  for (int i = 0; i < v.size(); i++) {
    if (i) cout << ", ";
    cout << v[i];
  }
  return cout << "]";
}
template <typename A, typename B>
istream& operator>>(istream& cin, pair<A, B>& p) {
  cin >> p.first;
  return cin >> p.second;
}
mt19937 rng(61378913);
void usaco(string filename) {
  freopen((filename + ".in").c_str(), "r", stdin);
  freopen((filename + ".out").c_str(), "w", stdout);
}
const long double pi = 3.14159265358979323846;
long long n, m, k, q, l, r, x, y, z;
long long a[1000005];
long long b[1000005];
long long c[1000005];
string second, t;
long long ans = 0;
template <int size, int lg, typename seg_t = long long>
struct hld {
  vector<int> edges[size];
  int bigchild[size];
  int sz[size];
  int depth[size];
  int chain[size];
  int label[size], label_time;
  int par[size];
  int lca_lift[size][lg];
  seg_t seg_tree[4 * size];
  seg_t seg_lazy[4 * size];
  int N;
  inline seg_t seg_combine(seg_t a, seg_t b) { return a + b; }
  inline seg_t seg_lazy_apply(seg_t lazy_val, seg_t new_val) { return new_val; }
  inline seg_t seg_lazy_func(seg_t cur_val, seg_t lazy_val, int l, int r) {
    return lazy_val;
  }
  const seg_t seg_sentinel = 0;
  const seg_t seg_lazy_sentinel = -1;
  const seg_t seg_init_val = 0;
  seg_t seg_query_header(int l, int r) {
    return seg_query_rec(0, 0, N - 1, l, r);
  }
  seg_t seg_query_rec(int i, int tl, int tr, int ql, int qr) {
    seg_eval_lazy(i, tl, tr);
    if (ql <= tl && tr <= qr) return seg_tree[i];
    if (tl > tr || tr < ql || qr < tl) return seg_sentinel;
    int mid = (tl + tr) / 2;
    seg_t a = seg_query_rec(2 * i + 1, tl, mid, ql, qr);
    seg_t b = seg_query_rec(2 * i + 2, mid + 1, tr, ql, qr);
    return seg_combine(a, b);
  }
  void seg_update_header(int l, int r, seg_t v) {
    seg_update_rec(0, 0, N - 1, l, r, v);
  }
  seg_t seg_update_rec(int i, int tl, int tr, int ql, int qr, seg_t v) {
    seg_eval_lazy(i, tl, tr);
    if (tl > tr || tr < ql || qr < tl) return seg_tree[i];
    if (ql <= tl && tr <= qr) {
      seg_lazy[i] = seg_lazy_apply(seg_lazy[i], v);
      seg_eval_lazy(i, tl, tr);
      return seg_tree[i];
    }
    if (tl == tr) return seg_tree[i];
    int mid = (tl + tr) / 2;
    seg_t a = seg_update_rec(2 * i + 1, tl, mid, ql, qr, v);
    seg_t b = seg_update_rec(2 * i + 2, mid + 1, tr, ql, qr, v);
    return seg_tree[i] = seg_combine(a, b);
  }
  void seg_eval_lazy(int i, int l, int r) {
    if (seg_lazy[i] == seg_lazy_sentinel) return;
    seg_tree[i] = seg_lazy_func(seg_tree[i], seg_lazy[i], l, r);
    if (l != r) {
      seg_lazy[i * 2 + 1] = seg_lazy_apply(seg_lazy[i * 2 + 1], seg_lazy[i]);
      seg_lazy[i * 2 + 2] = seg_lazy_apply(seg_lazy[i * 2 + 2], seg_lazy[i]);
    }
    seg_lazy[i] = seg_lazy_sentinel;
  }
  void init_arrays(int n) {
    N = n;
    for (int i = 0; i < N; i++) {
      edges[i].clear();
      chain[i] = i;
    }
    for (int i = 0; i < 4 * N; i++) {
      seg_tree[i] = seg_init_val;
      seg_lazy[i] = seg_lazy_sentinel;
    }
  }
  void add_edge(int u, int v) {
    edges[u].push_back(v);
    edges[v].push_back(u);
  }
  void init_tree(seg_t* arr, int root = 0) {
    lca_dfs(root, -1);
    dfs_size(root, -1, 0);
    dfs_chains(root, -1);
    label_time = 0;
    dfs_labels(arr, root, -1);
  }
  void lca_dfs(int v, int par) {
    lca_lift[v][0] = par;
    for (int i = 1; i < lg; i++) {
      if (lca_lift[v][i - 1] == -1)
        lca_lift[v][i] = -1;
      else
        lca_lift[v][i] = lca_lift[lca_lift[v][i - 1]][i - 1];
    }
    for (int x : edges[v]) {
      if (x != par) {
        lca_dfs(x, v);
      }
    }
  }
  void dfs_size(int v, int p, int d) {
    sz[v] = 1;
    depth[v] = d;
    par[v] = p;
    int bigc = -1, bigv = -1;
    for (int x : edges[v]) {
      if (x != p) {
        dfs_size(x, v, d + 1);
        sz[v] += sz[x];
        if (sz[x] > bigv) {
          bigc = x;
          bigv = sz[x];
        }
      }
    }
    bigchild[v] = bigc;
  }
  void dfs_chains(int v, int p) {
    if (bigchild[v] != -1) {
      chain[bigchild[v]] = chain[v];
    }
    for (int x : edges[v]) {
      if (x != p) {
        dfs_chains(x, v);
      }
    }
  }
  void dfs_labels(seg_t* arr, int v, int p) {
    label[v] = label_time++;
    seg_update_header(label[v], label[v], arr[v]);
    if (bigchild[v] != -1) {
      dfs_labels(arr, bigchild[v], v);
    }
    for (int x : edges[v]) {
      if (x != p && x != bigchild[v]) {
        dfs_labels(arr, x, v);
      }
    }
  }
  int lca(int a, int b) {
    if (depth[a] < depth[b]) swap(a, b);
    int d = depth[a] - depth[b];
    int v = get_kth_ancestor(a, d);
    if (v == b) {
      return v;
    } else {
      for (int i = lg - 1; i >= 0; i--) {
        if (lca_lift[v][i] != lca_lift[b][i]) {
          v = lca_lift[v][i];
          b = lca_lift[b][i];
        }
      }
      return lca_lift[b][0];
    }
  }
  int get_kth_ancestor(int v, int k) {
    for (int i = lg - 1; i >= 0; i--) {
      if (v == -1) return v;
      if ((1 << i) <= k) {
        v = lca_lift[v][i];
        k -= (1 << i);
      }
    }
    return v;
  }
  seg_t query_chain(int v, int p) {
    seg_t val = seg_sentinel;
    while (depth[p] < depth[v]) {
      int top = chain[v];
      if (depth[top] <= depth[p]) {
        int diff = depth[v] - depth[p];
        top = get_kth_ancestor(v, diff - 1);
      }
      val = seg_combine(val, seg_query_header(label[top], label[v]));
      v = par[top];
    }
    return val;
  }
  seg_t query(int u, int v) {
    int lc = lca(u, v);
    seg_t val = seg_combine(query_chain(u, lc), query_chain(v, lc));
    return seg_combine(val, seg_query_header(label[lc], label[lc]));
  }
  void update_chain(int v, int p, seg_t val) {
    while (depth[p] < depth[v]) {
      int top = chain[v];
      if (depth[top] <= depth[p]) {
        int diff = depth[v] - depth[p];
        top = get_kth_ancestor(v, diff - 1);
      }
      seg_update_header(label[top], label[v], val);
      v = par[top];
    }
  }
  void update(int u, int v, seg_t val) {
    int lc = lca(u, v);
    update_chain(u, lc, val);
    update_chain(v, lc, val);
    seg_update_header(label[lc], label[lc], val);
  }
};
hld<100005, 20, long long> h;
void solve(int tc) {
  cin >> n >> q;
  for (int ele = 0; ele < n; ele++) cin >> a[ele];
  ;
  for (int i = 0; i < n; i++) a[i] = abs(a[i]);
  h.init_arrays(n);
  for (long long i = 0; i < (n - 1); ++i) {
    cin >> x >> y;
    --x;
    --y;
    h.add_edge(x, y);
  }
  h.init_tree(a);
  for (long long i = 0; i < (q); ++i) {
    int t;
    cin >> t;
    if (t == 1) {
      int v;
      cin >> x >> v;
      --x;
      v = abs(v);
      a[x] = v;
      h.update(x, x, v);
    } else {
      cin >> x >> y;
      --x;
      --y;
      long long res = h.query(x, y) * 2ll;
      res -= a[x] + a[y];
      cout << res << '\n';
    }
  }
}
int main() {
  int tc = 1;
  for (int t = 0; t < tc; t++) solve(t);
}

### Prompt

Please create a solution in cpp to the following problem:

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.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
template <typename A>
ostream& operator<<(ostream& cout, vector<A> const& v);
template <typename A, typename B>
ostream& operator<<(ostream& cout, pair<A, B> const& p) {
  return cout << "(" << p.first << ", " << p.second << ")";
}
template <typename A>
ostream& operator<<(ostream& cout, vector<A> const& v) {
  cout << "[";
  for (int i = 0; i < v.size(); i++) {
    if (i) cout << ", ";
    cout << v[i];
  }
  return cout << "]";
}
template <typename A, typename B>
istream& operator>>(istream& cin, pair<A, B>& p) {
  cin >> p.first;
  return cin >> p.second;
}
mt19937 rng(61378913);
void usaco(string filename) {
  freopen((filename + ".in").c_str(), "r", stdin);
  freopen((filename + ".out").c_str(), "w", stdout);
}
const long double pi = 3.14159265358979323846;
long long n, m, k, q, l, r, x, y, z;
long long a[1000005];
long long b[1000005];
long long c[1000005];
string second, t;
long long ans = 0;
template <int size, int lg, typename seg_t = long long>
struct hld {
  vector<int> edges[size];
  int bigchild[size];
  int sz[size];
  int depth[size];
  int chain[size];
  int label[size], label_time;
  int par[size];
  int lca_lift[size][lg];
  seg_t seg_tree[4 * size];
  seg_t seg_lazy[4 * size];
  int N;
  inline seg_t seg_combine(seg_t a, seg_t b) { return a + b; }
  inline seg_t seg_lazy_apply(seg_t lazy_val, seg_t new_val) { return new_val; }
  inline seg_t seg_lazy_func(seg_t cur_val, seg_t lazy_val, int l, int r) {
    return lazy_val;
  }
  const seg_t seg_sentinel = 0;
  const seg_t seg_lazy_sentinel = -1;
  const seg_t seg_init_val = 0;
  seg_t seg_query_header(int l, int r) {
    return seg_query_rec(0, 0, N - 1, l, r);
  }
  seg_t seg_query_rec(int i, int tl, int tr, int ql, int qr) {
    seg_eval_lazy(i, tl, tr);
    if (ql <= tl && tr <= qr) return seg_tree[i];
    if (tl > tr || tr < ql || qr < tl) return seg_sentinel;
    int mid = (tl + tr) / 2;
    seg_t a = seg_query_rec(2 * i + 1, tl, mid, ql, qr);
    seg_t b = seg_query_rec(2 * i + 2, mid + 1, tr, ql, qr);
    return seg_combine(a, b);
  }
  void seg_update_header(int l, int r, seg_t v) {
    seg_update_rec(0, 0, N - 1, l, r, v);
  }
  seg_t seg_update_rec(int i, int tl, int tr, int ql, int qr, seg_t v) {
    seg_eval_lazy(i, tl, tr);
    if (tl > tr || tr < ql || qr < tl) return seg_tree[i];
    if (ql <= tl && tr <= qr) {
      seg_lazy[i] = seg_lazy_apply(seg_lazy[i], v);
      seg_eval_lazy(i, tl, tr);
      return seg_tree[i];
    }
    if (tl == tr) return seg_tree[i];
    int mid = (tl + tr) / 2;
    seg_t a = seg_update_rec(2 * i + 1, tl, mid, ql, qr, v);
    seg_t b = seg_update_rec(2 * i + 2, mid + 1, tr, ql, qr, v);
    return seg_tree[i] = seg_combine(a, b);
  }
  void seg_eval_lazy(int i, int l, int r) {
    if (seg_lazy[i] == seg_lazy_sentinel) return;
    seg_tree[i] = seg_lazy_func(seg_tree[i], seg_lazy[i], l, r);
    if (l != r) {
      seg_lazy[i * 2 + 1] = seg_lazy_apply(seg_lazy[i * 2 + 1], seg_lazy[i]);
      seg_lazy[i * 2 + 2] = seg_lazy_apply(seg_lazy[i * 2 + 2], seg_lazy[i]);
    }
    seg_lazy[i] = seg_lazy_sentinel;
  }
  void init_arrays(int n) {
    N = n;
    for (int i = 0; i < N; i++) {
      edges[i].clear();
      chain[i] = i;
    }
    for (int i = 0; i < 4 * N; i++) {
      seg_tree[i] = seg_init_val;
      seg_lazy[i] = seg_lazy_sentinel;
    }
  }
  void add_edge(int u, int v) {
    edges[u].push_back(v);
    edges[v].push_back(u);
  }
  void init_tree(seg_t* arr, int root = 0) {
    lca_dfs(root, -1);
    dfs_size(root, -1, 0);
    dfs_chains(root, -1);
    label_time = 0;
    dfs_labels(arr, root, -1);
  }
  void lca_dfs(int v, int par) {
    lca_lift[v][0] = par;
    for (int i = 1; i < lg; i++) {
      if (lca_lift[v][i - 1] == -1)
        lca_lift[v][i] = -1;
      else
        lca_lift[v][i] = lca_lift[lca_lift[v][i - 1]][i - 1];
    }
    for (int x : edges[v]) {
      if (x != par) {
        lca_dfs(x, v);
      }
    }
  }
  void dfs_size(int v, int p, int d) {
    sz[v] = 1;
    depth[v] = d;
    par[v] = p;
    int bigc = -1, bigv = -1;
    for (int x : edges[v]) {
      if (x != p) {
        dfs_size(x, v, d + 1);
        sz[v] += sz[x];
        if (sz[x] > bigv) {
          bigc = x;
          bigv = sz[x];
        }
      }
    }
    bigchild[v] = bigc;
  }
  void dfs_chains(int v, int p) {
    if (bigchild[v] != -1) {
      chain[bigchild[v]] = chain[v];
    }
    for (int x : edges[v]) {
      if (x != p) {
        dfs_chains(x, v);
      }
    }
  }
  void dfs_labels(seg_t* arr, int v, int p) {
    label[v] = label_time++;
    seg_update_header(label[v], label[v], arr[v]);
    if (bigchild[v] != -1) {
      dfs_labels(arr, bigchild[v], v);
    }
    for (int x : edges[v]) {
      if (x != p && x != bigchild[v]) {
        dfs_labels(arr, x, v);
      }
    }
  }
  int lca(int a, int b) {
    if (depth[a] < depth[b]) swap(a, b);
    int d = depth[a] - depth[b];
    int v = get_kth_ancestor(a, d);
    if (v == b) {
      return v;
    } else {
      for (int i = lg - 1; i >= 0; i--) {
        if (lca_lift[v][i] != lca_lift[b][i]) {
          v = lca_lift[v][i];
          b = lca_lift[b][i];
        }
      }
      return lca_lift[b][0];
    }
  }
  int get_kth_ancestor(int v, int k) {
    for (int i = lg - 1; i >= 0; i--) {
      if (v == -1) return v;
      if ((1 << i) <= k) {
        v = lca_lift[v][i];
        k -= (1 << i);
      }
    }
    return v;
  }
  seg_t query_chain(int v, int p) {
    seg_t val = seg_sentinel;
    while (depth[p] < depth[v]) {
      int top = chain[v];
      if (depth[top] <= depth[p]) {
        int diff = depth[v] - depth[p];
        top = get_kth_ancestor(v, diff - 1);
      }
      val = seg_combine(val, seg_query_header(label[top], label[v]));
      v = par[top];
    }
    return val;
  }
  seg_t query(int u, int v) {
    int lc = lca(u, v);
    seg_t val = seg_combine(query_chain(u, lc), query_chain(v, lc));
    return seg_combine(val, seg_query_header(label[lc], label[lc]));
  }
  void update_chain(int v, int p, seg_t val) {
    while (depth[p] < depth[v]) {
      int top = chain[v];
      if (depth[top] <= depth[p]) {
        int diff = depth[v] - depth[p];
        top = get_kth_ancestor(v, diff - 1);
      }
      seg_update_header(label[top], label[v], val);
      v = par[top];
    }
  }
  void update(int u, int v, seg_t val) {
    int lc = lca(u, v);
    update_chain(u, lc, val);
    update_chain(v, lc, val);
    seg_update_header(label[lc], label[lc], val);
  }
};
hld<100005, 20, long long> h;
void solve(int tc) {
  cin >> n >> q;
  for (int ele = 0; ele < n; ele++) cin >> a[ele];
  ;
  for (int i = 0; i < n; i++) a[i] = abs(a[i]);
  h.init_arrays(n);
  for (long long i = 0; i < (n - 1); ++i) {
    cin >> x >> y;
    --x;
    --y;
    h.add_edge(x, y);
  }
  h.init_tree(a);
  for (long long i = 0; i < (q); ++i) {
    int t;
    cin >> t;
    if (t == 1) {
      int v;
      cin >> x >> v;
      --x;
      v = abs(v);
      a[x] = v;
      h.update(x, x, v);
    } else {
      cin >> x >> y;
      --x;
      --y;
      long long res = h.query(x, y) * 2ll;
      res -= a[x] + a[y];
      cout << res << '\n';
    }
  }
}
int main() {
  int tc = 1;
  for (int t = 0; t < tc; t++) solve(t);
}

```