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;
inline int min(int a, int b) { return a < b ? a : b; }
inline int read() {
  int s = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();
  return s * f;
}
const int maxn = 8e5 + 10;
int n, q, tot, head[maxn], xx[maxn << 1], yy[maxn << 1];
struct data {
  int to, next, w;
} edge[maxn << 1];
int fa[maxn], sz[maxn], top[maxn], dep[maxn], son[maxn];
int seg[maxn << 2], w[maxn], ww[maxn];
int id[maxn], cnt, bian[maxn], num[maxn], ANS, d[maxn];
int LCA(int x, int y) {
  while (top[x] != top[y]) {
    if (dep[top[x]] < dep[top[y]]) swap(x, y);
    x = fa[top[x]];
  }
  if (dep[x] > dep[y]) swap(x, y);
  return x;
}
inline void pushup(int rt) { seg[rt] = seg[rt << 1] + seg[rt << 1 | 1]; }
void change(int rt, int lb, int rb, int kkk, int k) {
  if (kkk > rb || kkk < lb) return;
  if (lb == rb) {
    seg[rt] = k;
    return;
  }
  int mid = (lb + rb) >> 1;
  change(rt << 1, lb, mid, kkk, k), change(rt << 1 | 1, mid + 1, rb, kkk, k);
  pushup(rt);
}
int ask(int rt, int lb, int rb, int l, int r) {
  if (lb > r || l > rb) return 0;
  if (l <= lb && r >= rb) return seg[rt];
  int mid = (lb + rb) >> 1;
  return ask(rt << 1, lb, mid, l, r) + ask(rt << 1 | 1, mid + 1, rb, l, r);
}
void built(int rt, int lb, int rb) {
  if (lb == rb) {
    seg[rt] = w[lb];
    return;
  }
  int mid = (lb + rb) >> 1;
  built(rt << 1, lb, mid), built(rt << 1 | 1, mid + 1, rb);
  pushup(rt);
}
void dfs1(int x, int f, int Dep) {
  dep[x] = Dep;
  sz[x] = 1;
  fa[x] = f;
  int maxs = -1;
  for (int i = head[x]; i; i = edge[i].next) {
    int y = edge[i].to;
    dfs1(y, x, Dep + 1);
    sz[x] += sz[y];
    ww[y] = edge[i].w;
    if (sz[y] > maxs) maxs = sz[y], son[x] = y;
  }
}
void dfs2(int x, int Top) {
  top[x] = Top;
  id[x] = ++cnt;
  w[cnt] = ww[x];
  if (!son[x]) return;
  dfs2(son[x], Top);
  for (int i = head[x]; i; i = edge[i].next) {
    int y = edge[i].to;
    if (y == son[x]) continue;
    dfs2(y, y);
  }
}
int querysum(int x, int y) {
  int ans = 0;
  while (top[x] != top[y]) {
    if (dep[top[x]] < dep[top[y]]) swap(x, y);
    ans += ask(1, 1, n, id[top[x]], id[x]);
    x = fa[top[x]];
  }
  if (dep[x] > dep[y]) swap(x, y);
  if (x != y) ans += ask(1, 1, n, id[x] + 1, id[y]);
  return ans;
}
void dfsk(int x) {
  d[x] = bian[x];
  for (int i = head[x]; i; i = edge[i].next) {
    int y = edge[i].to;
    if (edge[i].w > d[x]) continue;
    dfsk(y);
    d[x] = min(d[x], min(edge[i].w + bian[y], edge[i].w + d[y]));
  }
}
int query(int x, int y) {
  int k = LCA(x, y);
  if (k == x)
    return querysum(x, y);
  else {
    dfsk(x);
    return querysum(1, y) + min(bian[x], d[x]);
  }
}
inline void make(int u, int v, int w) {
  edge[++tot] = (data){v, head[u], w};
  head[u] = tot;
}
int main() {
  n = read(), q = read();
  for (int i = 1; i < n; i++) {
    xx[i] = read(), yy[i] = read();
    int z = read();
    make(xx[i], yy[i], z);
  }
  for (int i = 1; i < n; i++) {
    int x = read(), y = read(), z = read();
    num[n - 1 + i] = max(x, y);
    bian[max(x, y)] = z;
  }
  dfs1(1, 0, 1);
  dfs2(1, 1);
  built(1, 1, n);
  for (int i = 1; i <= q; i++) {
    int opt = read(), x = read(), y = read();
    if (opt == 1) {
      if (x > n - 1)
        bian[num[x]] = y;
      else {
        change(1, 1, n, id[edge[x].to], y);
        edge[x].w = y;
      }
    }
    if (opt == 2) printf("%d\n", query(x, y));
  }
  return 0;
}