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 inf = 0x3fffffff;
const long long mod = 1000000007;
const int maxn = 2e5 + 100;
int n;
int head[maxn];
int cnt = 0;
int in[maxn], out[maxn], fin[maxn];
int d[maxn];
struct edge {
  int to, next;
} e[maxn * 2];
struct Edge {
  int u, v, w;
  Edge(int a = 0, int b = 0, int c = 0) : u(a), v(b), w(c) {}
} edge[maxn * 2];
struct node {
  int l, r;
  long long mi;
  long long lazy;
} seg[maxn * 4];
int tol = 0;
void add(int u, int v) {
  e[++tol].to = v, e[tol].next = head[u], head[u] = tol;
  e[++tol].to = u, e[tol].next = head[v], head[v] = tol;
}
void dfs(int x, int f) {
  in[x] = ++cnt;
  fin[cnt] = x;
  for (int i = head[x]; i; i = e[i].next) {
    int v = e[i].to;
    if (v == f) continue;
    dfs(v, x);
  }
  out[x] = cnt;
}
void pushdown(int i) {
  if (seg[i].l != seg[i].r && seg[i].lazy) {
    seg[i * 2].mi += seg[i].lazy;
    seg[i * 2].lazy += seg[i].lazy;
    seg[i * 2 + 1].mi += seg[i].lazy;
    seg[i * 2 + 1].lazy += seg[i].lazy;
    seg[i].lazy = 0;
  }
}
void pushup(int i) {
  if (seg[i].l != seg[i].r) {
    seg[i].mi = min(seg[i * 2].mi, seg[i * 2 + 1].mi);
  }
}
void build(int i, int l, int r) {
  seg[i].l = l, seg[i].r = r;
  seg[i].lazy = 0;
  if (l == r) {
    seg[i].mi = d[fin[l]];
    return;
  }
  int m = (l + r) / 2;
  build(i * 2, l, m);
  build(i * 2 + 1, m + 1, r);
  pushup(i);
}
void update(int i, int l, int r, long long v) {
  if (seg[i].l == l && seg[i].r == r) {
    seg[i].mi += v;
    seg[i].lazy += v;
    return;
  }
  pushdown(i);
  int m = (seg[i].l + seg[i].r) / 2;
  if (r <= m)
    update(i * 2, l, r, v);
  else if (l > m)
    update(i * 2 + 1, l, r, v);
  else {
    update(i * 2, l, m, v);
    update(i * 2 + 1, m + 1, r, v);
  }
  pushup(i);
}
long long query(int i, int l, int r) {
  if (seg[i].l == l && seg[i].r == r) {
    return seg[i].mi;
  }
  pushdown(i);
  int m = (seg[i].l + seg[i].r) / 2;
  if (r <= m)
    return query(i * 2, l, r);
  else if (l > m)
    return query(i * 2 + 1, l, r);
  else
    return min(query(i * 2, l, m), query(i * 2 + 1, m + 1, r));
}
int main() {
  int q;
  scanf("%d%d", &n, &q);
  tol = 0;
  cnt = 0;
  memset(head, 0, sizeof(head));
  for (int i = 1; i < 2 * n - 1; i++) {
    scanf("%d%d%d", &edge[i].u, &edge[i].v, &edge[i].w);
    if (i < n)
      add(edge[i].u, edge[i].v);
    else
      d[edge[i].u] = edge[i].w;
  }
  dfs(1, 0);
  build(1, 1, n);
  for (int i = 1; i < n; i++)
    update(1, in[edge[i].v], out[edge[i].v], edge[i].w);
  while (q--) {
    int k, u, v;
    scanf("%d%d%d", &k, &u, &v);
    if (k == 1) {
      if (u < n) {
        int t = edge[u].w;
        update(1, in[edge[u].v], out[edge[u].v], v - t);
      } else {
        update(1, in[edge[u].u], in[edge[u].u], v - edge[u].w);
        d[edge[u].u] = v;
      }
      edge[u].w = v;
    } else if (k == 2) {
      long long ans = query(1, in[v], in[v]) - d[v];
      ans += query(1, in[u], out[u]) - (query(1, in[u], in[u]) - d[u]);
      if (in[u] <= in[v] && out[v] <= out[u]) {
        long long t =
            query(1, in[v], in[v]) - d[v] - query(1, in[u], in[u]) + d[u];
        ans = min(ans, t);
      }
      printf("%lld\n", ans);
    }
  }
  return 0;
}