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 n, q;
struct haha {
  int l, r;
  long long minn, delta;
} tree[200000 * 4 + 5];
struct hehe {
  int to, next;
  long long v;
} e[200005];
long long daoyi[200005] = {0};
long long jvli[200005] = {0};
int l[200005], r[200005], weizhi[200005];
int dfsxu[200005];
int pos = 0;
int cnt = 0, h[200005] = {0};
int biantou[400005];
long long zhi[200005];
long long dist[200005];
void pushdown(int n) {
  if (tree[n].l == tree[n].r) {
    tree[n].delta = 0;
    return;
  }
  if (tree[n].delta == 0) return;
  tree[n << 1].minn += tree[n].delta;
  tree[n << 1 | 1].minn += tree[n].delta;
  tree[n << 1].delta += tree[n].delta;
  tree[n << 1 | 1].delta += tree[n].delta;
  tree[n].delta = 0;
}
void pushup(int n) {
  tree[n].minn = min(tree[n << 1].minn, tree[n << 1 | 1].minn);
}
void hmz(int n, int l, int r, long long delta) {
  if (tree[n].r < l || tree[n].l > r) return;
  if (l <= tree[n].l && tree[n].r <= r) {
    tree[n].minn += delta;
    tree[n].delta += delta;
    return;
  }
  pushdown(n);
  int mid = (tree[n].l + tree[n].r) / 2;
  if (r <= mid)
    hmz(n << 1, l, r, delta);
  else if (l > mid)
    hmz(n << 1 | 1, l, r, delta);
  else {
    hmz(n << 1, l, r, delta);
    hmz(n << 1 | 1, l, r, delta);
  }
  pushup(n);
}
void build(int n, int l, int r) {
  tree[n].l = l;
  tree[n].r = r;
  if (l == r) {
    tree[n].delta = 0;
    tree[n].minn = dist[dfsxu[l]] + daoyi[dfsxu[l]];
    return;
  }
  int mid = (l + r) / 2;
  build(n << 1, l, mid);
  build(n << 1 | 1, mid + 1, r);
  tree[n].delta = 0;
  tree[n].minn = min(tree[n << 1].minn, tree[n << 1 | 1].minn);
}
long long getminn(int n, int l, int r) {
  if (tree[n].r < l || tree[n].l > r) return 0;
  if (l <= tree[n].l && tree[n].r <= r) return tree[n].minn;
  pushdown(n);
  int mid = (tree[n].l + tree[n].r) / 2;
  long long ans;
  if (r <= mid)
    ans = getminn(n << 1, l, r);
  else if (l > mid)
    ans = getminn(n << 1 | 1, l, r);
  else
    ans = min(getminn(n << 1, l, r), getminn(n << 1 | 1, l, r));
  return ans;
}
void add(int x, int y, long long v) {
  cnt++;
  e[cnt].to = y;
  e[cnt].v = v;
  e[cnt].next = h[x];
  h[x] = cnt;
}
int lowbit(int x) { return x & (-x); }
void gai(int id, long long delta) {
  for (int i = id; i <= n; i += lowbit(i)) jvli[i] += delta;
}
long long getsum(int id) {
  long long ans = 0;
  for (int i = id; i; i -= lowbit(i)) ans += jvli[i];
  return ans;
}
void dfs(int x, int fa) {
  pos++;
  dfsxu[pos] = x;
  l[x] = pos;
  for (int i = h[x]; i; i = e[i].next) {
    int y = e[i].to;
    if (y == fa) continue;
    dist[y] = dist[x] + e[i].v;
    dfs(y, x);
  }
  r[x] = pos;
}
int main() {
  scanf("%d%d", &n, &q);
  for (int i = 1; i <= n - 1; i++) {
    int x, y;
    long long v;
    scanf("%d%d%lld", &x, &y, &v);
    biantou[i] = y;
    zhi[i] = v;
    add(x, y, v);
  }
  for (int i = n; i <= 2 * n - 2; i++) {
    int x, y;
    long long v;
    scanf("%d%d%lld", &x, &y, &v);
    biantou[i] = x;
    daoyi[x] = v;
  }
  dist[1] = 0;
  dfs(1, 1);
  build(1, 1, n);
  for (int i = 1; i <= n; i++) {
    gai(l[i], dist[i]);
    gai(l[i] + 1, -dist[i]);
  }
  for (int i = 1; i <= q; i++) {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    if (a == 1) {
      if (b <= n - 1) {
        int x = biantou[b];
        int delta = (long long)c - zhi[b];
        zhi[b] = (long long)c;
        gai(l[x], delta);
        gai(r[x] + 1, -delta);
        hmz(1, l[x], r[x], delta);
      } else {
        int x = biantou[b];
        int delta = (long long)c - daoyi[x];
        daoyi[x] = c;
        hmz(1, l[x], l[x], delta);
      }
    } else {
      if (b == c) {
        printf("0\n");
        continue;
      }
      long long ans1 = 0, ans2 = 0;
      if (l[c] > l[b] && l[c] <= r[b]) {
        ans1 = getsum(l[c]) - getsum(l[b]);
      } else {
        ans1 = getminn(1, l[b], r[b]) - getsum(l[b]);
        ans2 = getsum(l[c]);
      }
      printf("%lld\n", ans1 + ans2);
    }
  }
  return 0;
}