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 tree[(int)8e5 + 16], lazy[(int)8e5 + 16], pos[(int)4e5 + 9],
    tin[(int)4e5 + 9], tout[(int)4e5 + 9], curr, dis_to_root[(int)4e5 + 9];
vector<pair<int, int> > l[(int)4e5 + 9];
pair<int, int> edg[(int)4e5 + 9];
long long int bit[(int)4e5 + 9], maxi = 1e16;
void build(int node, int start, int end) {
  if (start == end) {
    tree[node] = dis_to_root[pos[start]];
    return;
  }
  int mid = (start + end) / 2;
  build(2 * node, start, mid);
  build(2 * node + 1, mid + 1, end);
  tree[node] = min(tree[2 * node], tree[2 * node + 1]);
  return;
}
void update(int node, int start, int end, int l, int r, int val) {
  if (lazy[node]) {
    tree[node] += lazy[node];
    if (start != end) {
      lazy[2 * node] += lazy[node];
      lazy[2 * node + 1] += lazy[node];
    }
    lazy[node] = 0;
  }
  if (start > end || start > r || end < l) {
    return;
  }
  if (start >= l && end <= r) {
    tree[node] += val;
    if (start != end) {
      lazy[2 * node] += val;
      lazy[2 * node + 1] += val;
    }
    return;
  }
  int mid = (start + end) / 2;
  update(2 * node, start, mid, l, r, val);
  update(2 * node + 1, mid + 1, end, l, r, val);
  tree[node] = min(tree[2 * node], tree[2 * node + 1]);
  return;
}
long long int query(int node, int start, int end, int l, int r) {
  if (start > end || start > r || end < l) {
    return maxi;
  }
  if (lazy[node]) {
    tree[node] += lazy[node];
    if (start != end) {
      lazy[2 * node] += lazy[node];
      lazy[2 * node + 1] += lazy[node];
    }
    lazy[node] = 0;
  }
  if (start >= l && end <= r) {
    return tree[node];
  }
  int mid = (start + end) / 2;
  long long int p1 = query(2 * node, start, mid, l, r);
  long long int p2 = query(2 * node + 1, mid + 1, end, l, r);
  return min(p1, p2);
}
void update(int idx, int val) {
  while (idx < (int)4e5 + 9) {
    bit[idx] += val;
    idx += (idx & -idx);
  }
  return;
}
long long int query(int idx) {
  long long int t1 = 0;
  while (idx) {
    t1 += bit[idx];
    idx -= (idx & -idx);
  }
  return t1;
}
void dfs(int ver, int par) {
  int i, j, t1, t2, t3, t4;
  tin[ver] = ++curr;
  pos[curr] = ver;
  for (auto it : l[ver]) {
    if (it.first == par) {
      continue;
    }
    dfs(it.first, ver);
  }
  tout[ver] = curr;
}
bool isAnc(int u, int v) { return (tin[u] <= tin[v] && tout[u] >= tout[v]); }
int main() {
  int i, j, t1, t2, t3, t4, n, q;
  long long int ans;
  scanf("%d %d", &n, &q);
  for (i = 1; i <= n - 1; i++) {
    scanf("%d %d %d", &t1, &t2, &t3);
    l[t1].push_back(make_pair(t2, t3));
    edg[i] = make_pair(t2, t3);
  }
  for (i = n; i <= 2 * n - 2; i++) {
    scanf("%d %d %d", &t1, &t2, &t3);
    dis_to_root[t1] = t3;
    edg[i] = make_pair(t1, t3);
  }
  dis_to_root[1] = 0;
  memset(lazy, 0, sizeof(lazy));
  memset(bit, 0, sizeof(bit));
  curr = 0;
  dfs(1, -1);
  build(1, 1, n);
  for (i = 1; i <= n - 1; i++) {
    update(tin[edg[i].first], edg[i].second);
    update(tout[edg[i].first] + 1, -edg[i].second);
    update(1, 1, n, tin[edg[i].first], tout[edg[i].first], edg[i].second);
  }
  while (q--) {
    scanf("%d %d %d", &t1, &t2, &t3);
    if (t1 == 1) {
      if (t2 >= n) {
        dis_to_root[edg[t2].first] = t3;
        update(1, 1, n, tin[edg[t2].first], tin[edg[t2].first],
               t3 - edg[t2].second);
        edg[t2].second = t3;
      } else {
        update(tin[edg[t2].first], t3 - edg[t2].second);
        update(tout[edg[t2].first] + 1, edg[t2].second - t3);
        update(1, 1, n, tin[edg[t2].first], tout[edg[t2].first],
               t3 - edg[t2].second);
        edg[t2].second = t3;
      }
    } else {
      if (isAnc(t2, t3)) {
        ans = query(tin[t3]) - query(tin[t2]);
      } else {
        ans =
            query(1, 1, n, tin[t2], tout[t2]) - query(tin[t2]) + query(tin[t3]);
      }
      printf("%lld\n", ans);
    }
  }
  return 0;
}