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 = 200000 + 10;
const long long inf = 1ll << 60;
const int maxh = 20;
int n, q, a[N * 2], b[N * 2], c[N * 2], rev[N], dfn[N], mxdfn[N], idfn, head[N],
    cnt;
long long bit[N], dist[N];
struct Edge {
  int nxt, to, val;
} e[N * 2];
void addedge(int u, int v, int w) {
  e[++cnt].nxt = head[u];
  e[cnt].to = v;
  e[cnt].val = w;
  head[u] = cnt;
}
const int MAXN = 200000 + 10;
long long add[MAXN << 2], mn[MAXN << 2];
void PushUp(int rt) { mn[rt] = min(mn[rt << 1], mn[rt << 1 | 1]); }
void PushDown(int rt, int m) {
  if (add[rt]) {
    add[rt << 1] += add[rt];
    add[rt << 1 | 1] += add[rt];
    mn[rt << 1] += add[rt];
    mn[rt << 1 | 1] += add[rt];
    add[rt] = 0;
  }
}
void build(int l, int r, int rt) {
  add[rt] = 0;
  if (l == r) {
    mn[rt] = dist[l];
    return;
  }
  int m = (l + r) >> 1;
  build(l, m, rt << 1);
  build(m + 1, r, rt << 1 | 1);
  PushUp(rt);
}
void update(int L, int R, long long w, int l, int r, int rt) {
  if (L > R) return;
  if (L <= l && r <= R) {
    add[rt] += w;
    mn[rt] += w;
    return;
  }
  PushDown(rt, r - l + 1);
  int m = (l + r) >> 1;
  if (L <= m) update(L, R, w, l, m, rt << 1);
  if (m < R) update(L, R, w, m + 1, r, rt << 1 | 1);
  PushUp(rt);
}
long long query(int L, int R, int l, int r, int rt) {
  if (L <= l && r <= R) return mn[rt];
  PushDown(rt, r - l + 1);
  int m = (l + r) >> 1;
  long long ret = inf;
  if (L <= m) ret = min(ret, query(L, R, l, m, rt << 1));
  if (m < R) ret = min(ret, query(L, R, m + 1, r, rt << 1 | 1));
  return ret;
}
int dep[N];
int anc[N][20];
void dfs(int rt) {
  static int Stack[N];
  int top = 0;
  dep[rt] = 1;
  for (int i = 0; i < maxh; i++) anc[rt][i] = rt;
  Stack[++top] = rt;
  while (top) {
    int x = Stack[top];
    if (x != rt) {
      for (int i = 1, y; i < maxh; i++)
        y = anc[x][i - 1], anc[x][i] = anc[y][i - 1];
    }
    for (int &i = head[x]; i; i = e[i].nxt) {
      int y = e[i].to;
      if (y != anc[x][0]) {
        dep[y] = dep[x] + 1;
        anc[y][0] = x;
        Stack[++top] = y;
      }
    }
    while (top && head[Stack[top]] == 0) top--;
  }
}
void swim(int &x, int H) {
  for (int i = 0; H; i++) {
    if (H & 1) x = anc[x][i];
    H /= 2;
  }
}
int lca(int x, int y) {
  int i;
  if (dep[x] > dep[y]) swap(x, y);
  swim(y, dep[y] - dep[x]);
  if (x == y) return x;
  for (;;) {
    for (i = 0; anc[x][i] != anc[y][i]; i++)
      ;
    if (i == 0) return anc[x][0];
    x = anc[x][i - 1];
    y = anc[y][i - 1];
  }
  return -1;
}
void getDfn(int rt, int fa, long long w) {
  dfn[rt] = ++idfn;
  dist[dfn[rt]] = w + rev[rt];
  for (int i = head[rt]; i; i = e[i].nxt) {
    if (e[i].to == fa) continue;
    getDfn(e[i].to, rt, w + e[i].val);
  }
  mxdfn[rt] = idfn;
}
int main() {
  scanf("%d %d", &n, &q);
  for (int i = 1; i <= 2 * n - 2; i++) {
    scanf("%d %d %d", &a[i], &b[i], &c[i]);
    if (i < n)
      addedge(a[i], b[i], c[i]), addedge(b[i], a[i], c[i]);
    else
      rev[a[i]] = c[i];
  }
  getDfn(1, 0, 0);
  dfs(1);
  build(1, n, 1);
  for (int op, i, w, u, v; q--;) {
    scanf("%d", &op);
    if (op == 1) {
      scanf("%d %d", &i, &w);
      if (i >= n) {
        update(dfn[a[i]], dfn[a[i]], w - rev[a[i]], 1, n, 1);
        rev[a[i]] = w;
      } else {
        update(dfn[b[i]], mxdfn[b[i]], w - c[i], 1, n, 1);
        c[i] = w;
      }
    } else {
      scanf("%d %d", &u, &v);
      if (lca(u, v) == u) {
        long long du = query(dfn[u], dfn[u], 1, n, 1) - rev[u];
        long long dv = query(dfn[v], dfn[v], 1, n, 1) - rev[v];
        printf("%lld\n", dv - du);
      } else {
        long long mnDist = query(dfn[u], mxdfn[u], 1, n, 1) -
                           query(dfn[u], dfn[u], 1, n, 1) + rev[u];
        long long dv = query(dfn[v], dfn[v], 1, n, 1) - rev[v];
        printf("%lld\n", mnDist + dv);
      }
    }
  }
}