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;
struct Edge {
  int from, to, w;
};
vector<Edge> tree[200005];
vector<Edge> es;
long long len[200005];
int siz[200005];
int rid[200005];
int id[200005];
int w[200005];
int tot;
long long sum[200005 << 2];
long long mi[200005 << 2];
long long lazy[200005 << 2];
void seq_build(int o, int l, int r) {
  if (l == r) {
    sum[o] = len[rid[l]];
    mi[o] = len[rid[l]] + w[rid[l]];
  } else {
    int mid = (l + r) >> 1;
    seq_build(o << 1, l, mid);
    seq_build(o << 1 | 1, mid + 1, r);
    sum[o] = sum[o << 1] + sum[o << 1 | 1];
    mi[o] = min(mi[o << 1], mi[o << 1 | 1]);
  }
}
void pushdown(int o, int l, int r) {
  if (lazy[o] != 0) {
    lazy[o << 1] += lazy[o];
    lazy[o << 1 | 1] += lazy[o];
    sum[o << 1] += lazy[o];
    sum[o << 1 | 1] += lazy[o];
    mi[o << 1] += lazy[o];
    mi[o << 1 | 1] += lazy[o];
    lazy[o] = 0;
  }
}
long long seq_querySum(int o, int l, int r, int ql, int qr) {
  if (ql <= l && r <= qr) return sum[o];
  if (r < ql || qr < l) return 0;
  int mid = (l + r) >> 1;
  pushdown(o, l, r);
  return seq_querySum(o << 1, l, mid, ql, qr) +
         seq_querySum(o << 1 | 1, mid + 1, r, ql, qr);
}
long long seq_queryMin(int o, int l, int r, int ql, int qr) {
  if (ql <= l && r <= qr) return mi[o];
  if (r < ql || qr < l) return 1LL << 50;
  int mid = (l + r) >> 1;
  pushdown(o, l, r);
  return min(seq_queryMin(o << 1, l, mid, ql, qr),
             seq_queryMin(o << 1 | 1, mid + 1, r, ql, qr));
}
void seq_modifySum(int o, int l, int r, int ql, int qr, int v) {
  if (ql <= l && r <= qr) {
    lazy[o] += v;
    sum[o] += v;
    mi[o] += v;
    return;
  }
  if (r < ql || qr < l) return;
  int mid = (l + r) >> 1;
  pushdown(o, l, r);
  seq_modifySum(o << 1, l, mid, ql, qr, v);
  seq_modifySum(o << 1 | 1, mid + 1, r, ql, qr, v);
  sum[o] = sum[o << 1] + sum[o << 1 | 1];
  mi[o] = min(mi[o << 1], mi[o << 1 | 1]);
}
void seq_modifyMin(int o, int l, int r, int q, int v) {
  if (l == r) {
    mi[o] += v;
    return;
  }
  int mid = (l + r) >> 1;
  pushdown(o, l, r);
  if (q <= mid)
    seq_modifyMin(o << 1, l, mid, q, v);
  else
    seq_modifyMin(o << 1 | 1, mid + 1, r, q, v);
  sum[o] = sum[o << 1] + sum[o << 1 | 1];
  mi[o] = min(mi[o << 1], mi[o << 1 | 1]);
}
int fa[200005][20];
int dep[200005];
void dfs(int cur, long long path) {
  id[cur] = ++tot;
  rid[tot] = cur;
  siz[cur] = 1;
  len[cur] = path;
  for (auto e : tree[cur]) {
    fa[e.to][0] = cur;
    dep[e.to] = dep[cur] + 1;
    dfs(e.to, path + e.w);
    siz[cur] += siz[e.to];
  }
}
void init(int n) {
  for (int j = 1; (1 << j) <= n; j++)
    for (int i = 1; i <= n; i++) fa[i][j] = fa[fa[i][j - 1]][j - 1];
}
int getlca(int a, int b) {
  if (dep[a] > dep[b]) swap(a, b);
  for (int i = 19; i >= 0; i--)
    if (dep[a] < dep[b] && dep[fa[b][i]] >= dep[a]) b = fa[b][i];
  for (int i = 19; i >= 0; i--)
    if (fa[a][i] != fa[b][i]) a = fa[a][i], b = fa[b][i];
  if (a == b) return a;
  return fa[a][0];
}
int main() {
  int n, q, a, b, c;
  scanf("%d%d", &n, &q);
  for (int i = 1; i < n; i++) {
    scanf("%d%d%d", &a, &b, &c);
    tree[a].push_back({0, b, c});
    es.push_back({a, b, c});
  }
  for (int i = 1; i < n; i++) {
    scanf("%d%d%d", &a, &b, &c);
    w[a] = c;
    es.push_back({a, b, c});
  }
  dep[1] = 1;
  dfs(1, 0);
  init(n);
  seq_build(1, 1, n);
  while (q--) {
    int op;
    scanf("%d", &op);
    if (op == 1) {
      int p, we;
      scanf("%d%d", &p, &we);
      p--;
      if (es[p].to == 1)
        seq_modifyMin(1, 1, n, id[es[p].from], we - es[p].w);
      else
        seq_modifySum(1, 1, n, id[es[p].to], id[es[p].to] + siz[es[p].to] - 1,
                      we - es[p].w);
      es[p].w = we;
    } else {
      int u, v;
      scanf("%d%d", &u, &v);
      if (getlca(u, v) == u)
        printf("%I64d\n", seq_querySum(1, 1, n, id[v], id[v]) -
                              seq_querySum(1, 1, n, id[u], id[u]));
      else
        printf("%I64d\n", seq_queryMin(1, 1, n, id[u], id[u] + siz[u] - 1) +
                              seq_querySum(1, 1, n, id[v], id[v]) -
                              seq_querySum(1, 1, n, id[u], id[u]));
    }
  }
  return 0;
}