Problem: You are given a directed weighted graph with n nodes and 2n - 2 edges. The nodes are labeled from 1 to n, while the edges are labeled from 1 to 2n - 2. The graph's edges can be split into two parts.

  * The first n - 1 edges will form a rooted spanning tree, with node 1 as the root. All these edges will point away from the root. 
  * The last n - 1 edges will be from node i to node 1, for all 2 ≤ i ≤ n. 



You are given q queries. There are two types of queries

  * 1 i w: Change the weight of the i-th edge to w
  * 2 u v: Print the length of the shortest path between nodes u to v



Given these queries, print the shortest path lengths.

Input

The first line of input will contain two integers n, q (2 ≤ n, q ≤ 200 000), the number of nodes, and the number of queries, respectively.

The next 2n - 2 integers will contain 3 integers ai, bi, ci, denoting a directed edge from node ai to node bi with weight ci.

The first n - 1 of these lines will describe a rooted spanning tree pointing away from node 1, while the last n - 1 of these lines will have bi = 1.

More specifically, 

  * The edges (a1, b1), (a2, b2), ... (an - 1, bn - 1) will describe a rooted spanning tree pointing away from node 1. 
  * bj = 1 for n ≤ j ≤ 2n - 2. 
  * an, an + 1, ..., a2n - 2 will be distinct and between 2 and n. 



The next q lines will contain 3 integers, describing a query in the format described in the statement.

All edge weights will be between 1 and 106.

Output

For each type 2 query, print the length of the shortest path in its own line.

Example

Input

5 9
1 3 1
3 2 2
1 4 3
3 5 4
5 1 5
3 1 6
2 1 7
4 1 8
2 1 1
2 1 3
2 3 5
2 5 2
1 1 100
2 1 3
1 8 30
2 4 2
2 2 4


Output

0
1
4
8
100
132
10

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
int n, Q;
int U[200005 << 1], V[200005 << 1], W[200005 << 1];
int to[200005], nxt[200005], hd[200005], val[200005], cnte;
void add(int u, int v, int w) {
  to[++cnte] = v;
  val[cnte] = w;
  nxt[cnte] = hd[u];
  hd[u] = cnte;
}
int E_Rt[200005];
int dep[200005], fa[200005], sz[200005], son[200005], top[200005];
long long dis[200005];
void dfs(int x, int f) {
  dep[x] = dep[f] + 1;
  fa[x] = f;
  sz[x] = 1;
  for (int i = hd[x], y; i; i = nxt[i]) {
    y = to[i];
    if (y == f) continue;
    dis[y] = dis[x] + val[i];
    dfs(y, x);
    sz[x] += sz[y];
    if (sz[y] > sz[son[x]]) son[x] = y;
  }
}
int L[200005], R[200005], ID[200005], tot;
void redfs(int x, int tp) {
  L[x] = ++tot;
  ID[tot] = x;
  top[x] = tp;
  if (son[x]) redfs(son[x], tp);
  for (int i = hd[x], y; i; i = nxt[i]) {
    y = to[i];
    if (y == fa[x] || y == son[x]) continue;
    redfs(y, y);
  }
  R[x] = tot;
}
int LCA(int u, int v) {
  while (top[u] != top[v]) {
    if (dep[top[u]] < dep[top[v]]) swap(u, v);
    u = fa[top[u]];
  }
  return dep[u] < dep[v] ? u : v;
}
long long mi[200005 << 2], lazy[200005 << 2];
void build(int L = 1, int R = n, int p = 1) {
  if (L == R) {
    mi[p] = dis[ID[L]] + E_Rt[ID[L]];
    return;
  }
  int mid = L + R >> 1;
  build(L, mid, p << 1);
  build(mid + 1, R, p << 1 | 1);
  mi[p] = min(mi[p << 1], mi[p << 1 | 1]);
}
void down(int p) {
  if (lazy[p]) {
    mi[p << 1] += lazy[p];
    mi[p << 1 | 1] += lazy[p];
    lazy[p << 1] += lazy[p];
    lazy[p << 1 | 1] += lazy[p];
    lazy[p] = 0;
  }
}
void update(int ql, int qr, int a, int L = 1, int R = n, int p = 1) {
  if (ql <= L && R <= qr) {
    mi[p] += a;
    lazy[p] += a;
    return;
  }
  down(p);
  int mid = L + R >> 1;
  if (qr <= mid)
    update(ql, qr, a, L, mid, p << 1);
  else if (ql > mid)
    update(ql, qr, a, mid + 1, R, p << 1 | 1);
  else
    update(ql, mid, a, L, mid, p << 1),
        update(mid + 1, qr, a, mid + 1, R, p << 1 | 1);
  mi[p] = min(mi[p << 1], mi[p << 1 | 1]);
}
long long query(int ql, int qr, int L = 1, int R = n, int p = 1) {
  if (ql <= L && R <= qr) return mi[p];
  down(p);
  int mid = L + R >> 1;
  if (qr <= mid)
    return query(ql, qr, L, mid, p << 1);
  else if (ql > mid)
    return query(ql, qr, mid + 1, R, p << 1 | 1);
  else
    return min(query(ql, mid, L, mid, p << 1),
               query(mid + 1, qr, mid + 1, R, p << 1 | 1));
}
void solve() {
  cin >> n >> Q;
  for (int i = 1; i < n; ++i) {
    scanf("%d%d%d", &U[i], &V[i], &W[i]);
    add(U[i], V[i], W[i]);
  }
  for (int i = n, u, v; i <= 2 * n - 2; ++i) {
    scanf("%d%d%d", &U[i], &V[i], &W[i]);
    E_Rt[U[i]] = W[i];
  }
  dfs(1, 0);
  redfs(1, 1);
  build();
  int opt, x, y, u, v, lca;
  long long dis_lca, dis_x, dis_y, res;
  while (Q--) {
    scanf("%d%d%d", &opt, &x, &y);
    if (opt == 1) {
      if (x >= n) {
        u = U[x];
        update(L[u], L[u], y - E_Rt[u]);
        E_Rt[u] = y;
      } else {
        u = U[x];
        v = V[x];
        if (dep[u] < dep[v]) swap(u, v);
        update(L[u], R[u], y - W[x]);
        W[x] = y;
      }
    } else {
      lca = LCA(x, y);
      dis_lca = query(L[lca], L[lca]) - E_Rt[lca];
      dis_x = query(L[x], L[x]) - E_Rt[x];
      dis_y = query(L[y], L[y]) - E_Rt[y];
      res = dis_y - dis_lca;
      if (x != lca) res += query(L[x], R[x]) - dis_x + dis_lca;
      printf("%lld\n", res);
    }
  }
}
int main() {
  solve();
  fclose(stdin);
  fclose(stdout);
  return 0;
}