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;
long long n;
struct qwq {
  long long v;
  long long w;
  long long nxt;
} edge[500010];
long long cnt = -1;
long long head[500010];
void add(long long u, long long v, long long w) {
  edge[++cnt].nxt = head[u];
  edge[cnt].v = v;
  edge[cnt].w = w;
  head[u] = cnt;
}
long long dep[500010];
long long fa[500010];
long long son[500010];
long long siz[500010];
long long dis[500010];
void dfs1(long long u, long long f) {
  siz[u] = 1;
  for (long long i = head[u]; ~i; i = edge[i].nxt) {
    long long v = edge[i].v;
    if (v == f) continue;
    fa[v] = u;
    dep[v] = dep[u] + 1;
    dis[v] = dis[u] + edge[i].w;
    dfs1(v, u);
    siz[u] += siz[v];
    if (siz[v] > siz[son[u]]) son[u] = v;
  }
}
long long tim;
long long dfn[500010];
long long rea[500010];
long long top[500010];
void dfs2(long long u, long long tp) {
  dfn[u] = ++tim;
  rea[tim] = u;
  top[u] = tp;
  if (son[u]) {
    dfs2(son[u], tp);
  }
  for (long long i = head[u]; ~i; i = edge[i].nxt) {
    long long v = edge[i].v;
    if (v == fa[u] || v == son[u]) continue;
    dfs2(v, v);
  }
}
long long minn[800010];
long long sum[800010];
long long sb[500010];
void up(long long o) { minn[o] = min(minn[o << 1], minn[o << 1 | 1]); }
long long tag[800010];
void down(long long o, long long v, long long type) {
  if (type == 0) sum[o] += v;
  tag[o] += v, minn[o] += v;
}
void pushdown(long long o) {
  if (tag[o]) {
    down(o << 1, tag[o], 0);
    down(o << 1 | 1, tag[o], 0);
    tag[o] = 0;
  }
}
void build(long long o, long long l, long long r) {
  if (l == r) {
    minn[o] = dis[rea[l]] + sb[rea[l]];
    sum[o] = dis[rea[l]];
    return;
  }
  long long mid = (l + r) / 2;
  build(o << 1, l, mid);
  build(o << 1 | 1, mid + 1, r);
  up(o);
}
void update(long long o, long long l, long long r, long long L, long long R,
            long long v, bool type) {
  if (L <= l && r <= R) {
    down(o, v, type);
    return;
  }
  pushdown(o);
  long long mid = (l + r) / 2;
  if (L <= mid) update(o << 1, l, mid, L, R, v, type);
  if (mid < R) update(o << 1 | 1, mid + 1, r, L, R, v, type);
  up(o);
}
long long queryminn(long long o, long long l, long long r, long long L,
                    long long R) {
  if (L <= l && r <= R) {
    return minn[o];
  }
  pushdown(o);
  long long mid = (l + r) / 2;
  long long ret = 19198e10;
  if (L <= mid) ret = min(ret, queryminn(o << 1, l, mid, L, R));
  if (mid < R) ret = min(ret, queryminn(o << 1 | 1, mid + 1, r, L, R));
  return ret;
}
long long queryx(long long o, long long l, long long r, long long x) {
  if (l == r) {
    return sum[o];
  }
  pushdown(o);
  long long mid = (l + r) / 2;
  if (x <= mid)
    return queryx(o << 1, l, mid, x);
  else
    return queryx(o << 1 | 1, mid + 1, r, x);
}
long long LCA(long long u, long long v) {
  while (top[u] != top[v]) {
    if (dep[u] < dep[v]) swap(u, v);
    u = fa[top[u]];
  }
  if (dep[u] > dep[v]) swap(u, v);
  return u;
}
long long query(long long u, long long v) {
  if (LCA(u, v) == u) {
    return queryx(1, 1, n, dfn[v]) - queryx(1, 1, n, dfn[u]);
  } else {
    return queryx(1, 1, n, dfn[v]) - queryx(1, 1, n, dfn[u]) +
           queryminn(1, 1, n, dfn[u], dfn[u] + siz[u] - 1);
  }
}
struct e {
  long long v;
  long long fa, u;
} ed[500010];
void change(long long i, long long v) {
  if (i <= n - 1) {
    update(1, 1, n, dfn[ed[i].u], dfn[ed[i].u] + siz[ed[i].u] - 1, v - ed[i].v,
           0);
    ed[i].v = v;
  } else {
    update(1, 1, n, dfn[ed[i].u], dfn[ed[i].u], v - sb[ed[i].u], 1);
    sb[ed[i].u] = v;
  }
}
signed main() {
  memset(head, -1, sizeof(head));
  long long q;
  scanf("%lld%lld", &n, &q);
  for (long long i = 1; i < n; ++i) {
    long long u, v, w;
    scanf("%lld%lld%lld", &u, &v, &w);
    add(u, v, w), add(v, u, w);
    ed[i].fa = u, ed[i].u = v, ed[i].v = w;
  }
  for (long long i = 1; i < n; ++i) {
    long long u, v;
    scanf("%lld%lld", &u, &v);
    scanf("%lld", &sb[u]);
    ed[i + n - 1].u = u;
  }
  dfs1(1, -1), dfs2(1, 1);
  build(1, 1, n);
  for (long long i = 1; i <= q; ++i) {
    long long opt, x, y;
    scanf("%lld%lld%lld", &opt, &x, &y);
    if (opt == 1) {
      change(x, y);
    } else {
      printf("%lld\n", query(x, y));
    }
  }
}