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, qu, toroot[200005], d[200005], par[200005][20], LG;
int tin[200005], tout[200005], stamp;
vector<pair<int, int> > v[200005];
struct BIT {
  int v;
  vector<long long> tree, lazy;
  BIT() {}
  BIT(int V) : v(V), tree(4 * V), lazy(4 * V) {}
  void push(int x, int L, int R, int mid) {
    if (lazy[x]) {
      tree[x + x] += lazy[x];
      tree[x + x + 1] += lazy[x];
      lazy[x + x] += lazy[x];
      lazy[x + x + 1] += lazy[x];
      lazy[x] = 0;
    }
  }
  void udt(int x, int L, int R, int le, int ri, long long val) {
    if (ri < L || R < le) return;
    if (le <= L && R <= ri) {
      tree[x] += val;
      lazy[x] += val;
      return;
    }
    int mid = (L + R) >> 1;
    push(x, L, R, mid);
    udt(x + x, L, mid, le, ri, val);
    udt(x + x + 1, mid + 1, R, le, ri, val);
    tree[x] = min(tree[x + x], tree[x + x + 1]);
  }
  long long getval(int x, int L, int R, int le, int ri) {
    if (ri < L || R < le) return 1e18;
    if (le <= L && R <= ri) {
      return tree[x];
    }
    int mid = (L + R) >> 1;
    push(x, L, R, mid);
    long long ret = getval(x + x, L, mid, le, ri);
    long long ret2 = getval(x + x + 1, mid + 1, R, le, ri);
    ret = min(ret, ret2);
    return ret;
  }
} bit, bit2;
struct Edge {
  int n1, n2, w;
} E[400005];
void dfs(int now, int pre, long long sum) {
  tin[now] = ++stamp;
  bit.udt(1, 1, n, tin[now], tin[now], sum);
  bit2.udt(1, 1, n, tin[now], tin[now], sum + (long long)toroot[now]);
  par[now][0] = pre;
  for (int i = 0; i < v[now].size(); i++) {
    int next = v[now][i].first;
    if (next == pre) continue;
    d[next] = d[now] + 1;
    dfs(next, now, sum + (long long)v[now][i].second);
  }
  tout[now] = stamp;
}
int get_par(int a, int gap) {
  for (int i = 0; (1 << i) <= gap; i++) {
    if (gap & (1 << i)) a = par[a][i];
  }
  return a;
}
int LCA(int a, int b) {
  if (d[a] < d[b]) swap(a, b);
  a = get_par(a, d[a] - d[b]);
  if (a == b) return a;
  for (int i = LG; i >= 0; i--) {
    if (par[a][i] != par[b][i]) {
      a = par[a][i];
      b = par[b][i];
    }
  }
  return par[a][0];
}
int main() {
  LG = 19;
  scanf("%d %d", &n, &qu);
  for (int a, b, c, i = 1; i <= n - 1; i++) {
    scanf("%d %d %d", &a, &b, &c);
    v[a].push_back(make_pair(b, c));
    E[i].n1 = a;
    E[i].n2 = b;
    E[i].w = c;
  }
  for (int a, b, c, i = n; i <= 2 * n - 2; i++) {
    scanf("%d %d %d", &a, &b, &c);
    toroot[a] = c;
    E[i].n1 = a;
    E[i].n2 = b;
    E[i].w = c;
  }
  bit = BIT(n);
  bit2 = BIT(n);
  dfs(1, 1, 0);
  for (int j = 1; j <= LG; j++) {
    for (int i = 1; i <= n; i++) {
      par[i][j] = par[par[i][j - 1]][j - 1];
    }
  }
  for (int ty, p, q, i = 1; i <= qu; i++) {
    scanf("%d %d %d", &ty, &p, &q);
    if (ty == 1) {
      if (p <= n - 1) {
        long long var = q - E[p].w;
        bit.udt(1, 1, n, tin[E[p].n2], tout[E[p].n2], var);
        bit2.udt(1, 1, n, tin[E[p].n2], tout[E[p].n2], var);
        E[p].w = q;
      } else {
        long long var = q - toroot[E[p].n1];
        bit2.udt(1, 1, n, tin[E[p].n1], tin[E[p].n1], var);
        toroot[E[p].n1] = q;
      }
    } else {
      int an = LCA(p, q);
      if (an == p) {
        long long var = bit.getval(1, 1, n, tin[p], tin[p]);
        long long var2 = bit.getval(1, 1, n, tin[q], tin[q]);
        var2 -= var;
        printf("%I64d\n", var2);
      } else {
        long long var = bit2.getval(1, 1, n, tin[p], tout[p]);
        var -= bit.getval(1, 1, n, tin[p], tin[p]);
        var += bit.getval(1, 1, n, tin[q], tin[q]);
        printf("%I64d\n", var);
      }
    }
  }
}