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 = 2e5 + 123;
long long lazy[N * 5], it[N * 5], dis[N];
int mn[N], mx[N], gt[N], w[N], cs[N * 2], a[N], Time;
vector<int> ed[N];
void load() {}
void dfs(int u) {
  mn[u] = mx[u] = ++Time;
  for (int v : ed[u]) {
    dis[v] = dis[u] + a[v];
    dfs(v);
    mx[u] = max(mx[u], mx[v]);
  }
  return;
}
void down(int k, int l, int r) {
  lazy[k * 2] += lazy[k];
  lazy[k * 2 + 1] += lazy[k];
  it[k * 2] += lazy[k];
  it[k * 2 + 1] += lazy[k];
  lazy[k] = 0;
  return;
}
void update(int k, int x, int y, int l, int r, int val) {
  if (l > y || r < x) return;
  if (l >= x && r <= y) {
    it[k] += val;
    lazy[k] += val;
    return;
  }
  down(k, l, r);
  int mid = (l + r) / 2;
  update(k * 2, x, y, l, mid, val);
  update(k * 2 + 1, x, y, mid + 1, r, val);
  it[k] = min(it[k * 2], it[k * 2 + 1]);
  return;
}
long long get(int k, int x, int y, int l, int r) {
  if (l > y || r < x) return 1e18;
  if (l >= x && r <= y) return it[k];
  down(k, l, r);
  int mid = (l + r) / 2;
  return min(get(k * 2, x, y, l, mid), get(k * 2 + 1, x, y, mid + 1, r));
}
void trungtt() {
  int n, q;
  scanf("%d%d", &n, &q);
  for (int i = 1; i < n; ++i) {
    int u, v, c;
    scanf("%d%d%d", &u, &v, &c);
    a[v] = c;
    cs[i] = v;
    ed[u].push_back(v);
  }
  Time = 0;
  for (int i = 2; i <= n; ++i) {
    int u, v, c;
    scanf("%d%d%d", &u, &v, &c);
    w[u] = c;
    cs[n + i - 2] = u;
  }
  dfs(1);
  for (int i = 1; i <= n; ++i) update(1, mn[i], mn[i], 1, n, dis[i] + w[i]);
  while (q--) {
    int typ, u, v;
    scanf("%d%d%d", &typ, &u, &v);
    if (typ == 1) {
      if (u >= n) {
        int t = cs[u];
        update(1, mn[t], mn[t], 1, n, v - w[t]);
        w[t] = v;
      } else {
        int t = cs[u];
        update(1, mn[t], mx[t], 1, n, v - a[t]);
        a[t] = v;
      }
    } else {
      long long ans = 1e18;
      ans = get(1, mn[u], mx[u], 1, n) - get(1, mn[u], mn[u], 1, n) + w[u] +
            get(1, mn[v], mn[v], 1, n) - w[v];
      if (mn[v] >= mn[u] && mn[v] <= mx[u])
        ans = min(ans, get(1, mn[v], mn[v], 1, n) - get(1, mn[u], mn[u], 1, n) -
                           w[v] + w[u]);
      printf("%lld\n", ans);
    }
  }
}
int main() {
  load();
  trungtt();
  return 0;
}