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 long long infll = 0x3f3f3f3f3f3f3f3f;
struct SegTree {
  static const int size = 1 << 18;
  long long data[size * 2], f[size * 2];
  void pushdown(int x) {
    data[x] += f[x];
    f[x * 2] += f[x];
    f[x * 2 + 1] += f[x];
    f[x] = 0;
  }
  void update(int x, int nl, int nr, int l, int r, long long v) {
    if (nl > r || nr < l) return;
    if (nl >= l && nr <= r) {
      f[x] += v;
      return;
    }
    pushdown(x);
    int mid = (nl + nr) / 2;
    update(x * 2, nl, mid, l, r, v);
    update(x * 2 + 1, mid + 1, nr, l, r, v);
    data[x] = min(data[x * 2] + f[x * 2], data[x * 2 + 1] + f[x * 2 + 1]);
  }
  void update(int l, int r, long long v) {
    assert(l <= r);
    update(1, 0, size - 1, l, r, v);
  }
  long long query(int x, int nl, int nr, int l, int r) {
    if (nl > r || nr < l) return infll;
    if (nl >= l && nr <= r) return data[x] + f[x];
    int mid = (nl + nr) / 2;
    return min(query(x * 2, nl, mid, l, r),
               query(x * 2 + 1, mid + 1, nr, l, r)) +
           f[x];
  }
  long long query(int l, int r) {
    assert(l <= r);
    return query(1, 0, size - 1, l, r);
  }
};
int n, q, cnt, l[200005], r[200005];
int depth[200005], par[200005][25], revlen[200005];
int eid[200005], revid[200005], ew[200005], revw[200005];
vector<pair<int, int> > g[200005];
SegTree dist, loop;
void dfs(int x, long long curr, int cpar, int cdepth) {
  par[x][0] = cpar;
  depth[x] = cdepth;
  l[x] = cnt;
  dist.update(cnt, cnt, curr);
  loop.update(cnt, cnt, curr + revlen[x]);
  cnt++;
  for (size_t i = 0; i < g[x].size(); i++) {
    dfs(g[x][i].first, curr + g[x][i].second, x, cdepth + 1);
  }
  r[x] = cnt - 1;
}
int lca(int x, int y) {
  for (int i = 20; i >= 0; i--)
    if (par[x][i] != -1 && depth[par[x][i]] >= depth[y]) x = par[x][i];
  for (int i = 20; i >= 0; i--)
    if (par[y][i] != -1 && depth[par[y][i]] >= depth[x]) y = par[y][i];
  assert(depth[x] == depth[y]);
  for (int i = 20; i >= 0; i--)
    if (par[x][i] != par[y][i]) x = par[x][i], y = par[y][i];
  if (x != y) x = par[x][0], y = par[y][0];
  assert(x == y);
  return x;
}
int main() {
  scanf("%d %d", &n, &q);
  for (int i = 0; i < n - 1; i++) {
    int a, b, w;
    scanf("%d %d %d", &a, &b, &w);
    a--, b--;
    g[a].push_back(make_pair(b, w));
    eid[i] = b;
    ew[i] = w;
  }
  for (int i = 0; i < n - 1; i++) {
    int a, b, w;
    scanf("%d %d %d", &a, &b, &w);
    a--, b--;
    assert(b == 0);
    revlen[a] = w;
    revid[i] = a;
    revw[i] = w;
  }
  dfs(0, 0, -1, 0);
  for (int i = 1; i <= 20; i++)
    for (int j = 0; j < n; j++)
      if (par[j][i - 1] != -1)
        par[j][i] = par[par[j][i - 1]][i - 1];
      else
        par[j][i] = -1;
  while (q--) {
    int op, a, b;
    scanf("%d %d %d", &op, &a, &b);
    if (op == 1) {
      a--;
      if (a < n - 1) {
        dist.update(l[eid[a]], r[eid[a]], b - ew[a]);
        loop.update(l[eid[a]], r[eid[a]], b - ew[a]);
        ew[a] = b;
      } else {
        a -= n - 1;
        loop.update(l[revid[a]], l[revid[a]], b - revw[a]);
        revw[a] = b;
      }
    } else {
      a--, b--;
      int ca = lca(a, b);
      if (ca == a) {
        printf("%I64d\n", dist.query(l[b], l[b]) - dist.query(l[a], l[a]));
        continue;
      }
      long long back = loop.query(l[a], r[a]) - dist.query(l[a], l[a]);
      long long res = back + dist.query(l[b], l[b]);
      printf("%I64d\n", res);
    }
  }
  return 0;
}