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;
int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * f;
}
struct Edge {
  int u, d;
  Edge() {}
  Edge(int _, int __) : u(_), d(__) {}
} es[400010];
int N, eid[200010];
int n, m, head[200010], nxt[200010], to[200010], dist[200010];
void AddEdge(int a, int b, int c) {
  to[++m] = b;
  dist[m] = c;
  nxt[m] = head[a];
  head[a] = m;
  return;
}
int dl[200010], dr[200010], clo, uid[200010];
long long dep[200010];
void build(int u) {
  dl[u] = ++clo;
  uid[clo] = u;
  for (int e = head[u]; e; e = nxt[e]) {
    dep[to[e]] = dep[u] + dist[e];
    build(to[e]);
  }
  dr[u] = clo;
  return;
}
long long addv[200010 << 2], minv[200010 << 2];
void build(int o, int l, int r) {
  if (l == r)
    minv[o] = dep[uid[l]] + es[eid[uid[l]]].d;
  else {
    int mid = l + r >> 1, lc = o << 1, rc = lc | 1;
    build(lc, l, mid);
    build(rc, mid + 1, r);
    minv[o] = min(minv[lc], minv[rc]);
  }
  return;
}
void pushdown(int o, int l, int r) {
  if (!addv[o] || l == r) {
    addv[o] = 0;
    return;
  }
  int lc = o << 1, rc = lc | 1, mid = l + r >> 1;
  addv[lc] += addv[o];
  minv[lc] += addv[o];
  if (l == mid) dep[uid[l]] += addv[o];
  addv[rc] += addv[o];
  minv[rc] += addv[o];
  if (mid + 1 == r) dep[uid[r]] += addv[o];
  addv[o] = 0;
  return;
}
void update(int o, int l, int r, int ql, int qr, int v) {
  pushdown(o, l, r);
  if (ql <= l && r <= qr) {
    addv[o] += v;
    minv[o] += v;
    if (l == r) dep[uid[l]] += v;
  } else {
    int mid = l + r >> 1, lc = o << 1, rc = lc | 1;
    if (ql <= mid) update(lc, l, mid, ql, qr, v);
    if (qr > mid) update(rc, mid + 1, r, ql, qr, v);
    minv[o] = min(minv[lc], minv[rc]);
  }
  return;
}
void changex(int o, int l, int r, int x, int v) {
  pushdown(o, l, r);
  if (l == r)
    minv[o] = dep[uid[l]] + (es[eid[uid[l]]].d = v);
  else {
    int mid = l + r >> 1, lc = o << 1, rc = lc | 1;
    if (dl[x] <= mid)
      changex(lc, l, mid, x, v);
    else
      changex(rc, mid + 1, r, x, v);
    minv[o] = min(minv[lc], minv[rc]);
  }
  return;
}
long long query(int o, int l, int r, int x) {
  pushdown(o, l, r);
  if (l == r) return dep[x];
  int mid = l + r >> 1, lc = o << 1, rc = lc | 1;
  if (dl[x] <= mid) return query(lc, l, mid, x);
  return query(rc, mid + 1, r, x);
}
long long qmin(int o, int l, int r, int ql, int qr) {
  pushdown(o, l, r);
  if (ql <= l && r <= qr) return minv[o];
  int mid = l + r >> 1, lc = o << 1, rc = lc | 1;
  long long ans = (1ll << 60);
  if (ql <= mid) ans = min(ans, qmin(lc, l, mid, ql, qr));
  if (qr > mid) ans = min(ans, qmin(rc, mid + 1, r, ql, qr));
  return ans;
}
int main() {
  n = read();
  N = (n << 1) - 2;
  int q = read();
  for (int i = 1; i <= N; i++) {
    int a = read(), b = read(), d = read();
    if (i <= (N >> 1))
      AddEdge(a, b, d), es[i] = Edge(b, d);
    else
      eid[a] = i, es[i] = Edge(a, d);
  }
  build(1);
  build(1, 1, n);
  while (q--) {
    int tp = read(), a = read(), b = read();
    if (tp == 1) {
      if (a > (N >> 1))
        changex(1, 1, n, es[a].u, b);
      else {
        update(1, 1, n, dl[es[a].u], dr[es[a].u], b - es[a].d);
        es[a].d = b;
      }
    }
    if (tp == 2) {
      if (dl[a] <= dl[b] && dr[b] <= dr[a])
        printf("%I64d\n", query(1, 1, n, b) - query(1, 1, n, a));
      else
        printf("%I64d\n", qmin(1, 1, n, dl[a], dr[a]) - query(1, 1, n, a) +
                              query(1, 1, n, b));
    }
  }
  return 0;
}