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;
const int N = 2e5 + 5;
struct Edge {
  int v, w, nxt;
} edge[N << 1];
struct Data {
  int u, v, w;
} e[N << 1];
int n, m, head[N], cnt, dis[N];
int dfn[N], ind, rnd[N], sz[N], up[N], dep[N];
int minn[N * 4], st[N * 4], tag[N * 4];
void add(int u, int v, int w) {
  edge[++cnt].v = v;
  edge[cnt].w = w;
  edge[cnt].nxt = head[u];
  head[u] = cnt;
}
void build(int u, int l, int r) {
  if (l == r) {
    minn[u] = dis[rnd[l]] + up[rnd[l]];
    st[u] = up[rnd[l]];
    return;
  }
  int mid = (l + r) / 2;
  build(u << 1, l, mid);
  build(u << 1 | 1, mid + 1, r);
  minn[u] = min(minn[u << 1], minn[u << 1 | 1]);
}
void pushdown(int u, int l, int r) {
  if (tag[u]) {
    minn[u << 1] += tag[u];
    st[u << 1] += tag[u];
    tag[u << 1] += tag[u];
    minn[u << 1 | 1] += tag[u];
    st[u << 1 | 1] += tag[u];
    tag[u << 1 | 1] += tag[u];
    tag[u] = 0;
  }
}
void update0(int u, int l, int r, int a, int b, int k) {
  if (a <= l && r <= b) {
    minn[u] += k;
    st[u] += k;
    tag[u] += k;
    return;
  }
  pushdown(u, l, r);
  int mid = (l + r) / 2;
  if (a <= mid) update0(u << 1, l, mid, a, b, k);
  if (mid < b) update0(u << 1 | 1, mid + 1, r, a, b, k);
  minn[u] = min(minn[u << 1], minn[u << 1 | 1]);
}
void update1(int u, int l, int r, int x, int k) {
  if (l == r) {
    minn[u] += k;
    return;
  }
  pushdown(u, l, r);
  int mid = (l + r) / 2;
  if (x <= mid)
    update1(u << 1, l, mid, x, k);
  else
    update1(u << 1 | 1, mid + 1, r, x, k);
  minn[u] = min(minn[u << 1], minn[u << 1 | 1]);
}
int query0(int u, int l, int r, int x) {
  if (l == r) return st[u];
  pushdown(u, l, r);
  int mid = (l + r) / 2;
  if (x <= mid)
    return query0(u << 1, l, mid, x);
  else
    return query0(u << 1 | 1, mid + 1, r, x);
}
int query1(int u, int l, int r, int a, int b) {
  if (a <= l && r <= b) return minn[u];
  pushdown(u, l, r);
  int mid = (l + r) / 2;
  int ans1 = 2e9, ans2 = 2e9;
  if (a <= mid) ans1 = query1(u << 1, l, mid, a, b);
  if (mid < b) ans2 = query1(u << 1 | 1, mid + 1, r, a, b);
  return min(ans1, ans2);
}
void dfs(int u) {
  dfn[u] = ++ind;
  rnd[ind] = u;
  sz[u] = 1;
  for (int i = head[u]; i; i = edge[i].nxt) {
    int v = edge[i].v;
    int w = edge[i].w;
    up[v] = up[u] + w;
    dep[v] = dep[u] + 1;
    dfs(v);
    sz[u] += sz[v];
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n - 1; i++) {
    scanf("%d%d%d", &e[i].u, &e[i].v, &e[i].w);
    add(e[i].u, e[i].v, e[i].w);
  }
  for (int i = n; i <= 2 * n - 2; i++) {
    scanf("%d%d%d", &e[i].u, &e[i].v, &e[i].w);
    dis[e[i].u] = e[i].w;
  }
  dfs(1);
  build(1, 1, n);
  int t, x, y;
  while (m--) {
    scanf("%d%d%d", &t, &x, &y);
    if (t == 1) {
      if (x <= n - 1) {
        int u = e[x].u, v = e[x].v;
        if (dep[u] < dep[v]) swap(u, v);
        update0(1, 1, n, dfn[u], dfn[u] + sz[u] - 1, -e[x].w + y);
        e[x].w = y;
      } else
        update1(1, 1, n, dfn[e[x].u], -e[x].w + y);
      e[x].w = y;
      dis[e[x].u] = y;
    } else {
      int up_x = query0(1, 1, n, dfn[x]);
      int up_y = query0(1, 1, n, dfn[y]);
      if (dfn[x] <= dfn[y] && dfn[y] <= dfn[x] + sz[x] - 1)
        printf("%d\n", up_y - up_x);
      else {
        printf("%d\n",
               query1(1, 1, n, dfn[x], dfn[x] + sz[x] - 1) - up_x + up_y);
      }
    }
  }
  return 0;
}