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;
long long n, q, t = 0, number = 0;
vector<vector<vector<long long>>> graph;
vector<long long> edgesroot;
vector<long long> tin;
vector<long long> num;
vector<long long> tout;
vector<long long> sub;
vector<long long> dist;
vector<long long> revnum;
vector<vector<long long>> edges;
void dfs(long long v) {
  tin[v] = t++;
  num[v] = number++;
  for (auto h : graph[v]) {
    dist[h[0]] = dist[v] + h[1];
    dfs(h[0]);
    sub[v] += sub[h[0]];
  }
  tout[v] = t++;
}
struct node {
  long long add = 0;
  long long Min = 1e10;
  node() {}
  node(long long x) { Min = x; }
};
long long Size;
vector<node> tree;
void init() {
  Size = 1 << (long long)ceil(log2(n));
  tree.assign(2 * Size - 1, node());
}
void push(long long id, long long l, long long r) {
  if (r - l == 1) return;
  if (tree[id].add == 0) return;
  long long mid = (l + r) / 2;
  tree[id * 2 + 1].Min += tree[id].add;
  tree[id * 2 + 1].add += tree[id].add;
  tree[id * 2 + 2].Min += tree[id].add;
  tree[id * 2 + 2].add += tree[id].add;
  tree[id].add = 0;
}
void build(long long id, long long l, long long r) {
  if (r - l == 1) {
    if (l < n) tree[id] = node(dist[revnum[l]] + edgesroot[revnum[l]]);
    return;
  }
  long long mid = (l + r) / 2;
  build(id * 2 + 1, l, mid);
  build(id * 2 + 2, mid, r);
  tree[id].Min = min(tree[id * 2 + 1].Min, tree[id * 2 + 2].Min);
}
void addRange(long long id, long long l, long long r, long long lq,
              long long rq, long long x) {
  push(id, l, r);
  if (l >= rq or r <= lq) return;
  if (lq <= l and r <= rq) {
    tree[id].Min += x;
    tree[id].add += x;
    return;
  }
  long long mid = (l + r) / 2;
  addRange(id * 2 + 1, l, mid, lq, rq, x);
  addRange(id * 2 + 2, mid, r, lq, rq, x);
  tree[id].Min = min(tree[id * 2 + 1].Min, tree[id * 2 + 2].Min);
}
long long getMin(long long id, long long l, long long r, long long lq,
                 long long rq) {
  push(id, l, r);
  if (l >= rq or r <= lq) return 1e10;
  if (lq <= l and r <= rq) return tree[id].Min;
  long long mid = (l + r) / 2;
  return min(getMin(id * 2 + 1, l, mid, lq, rq),
             getMin(id * 2 + 2, mid, r, lq, rq));
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> q;
  graph.assign(n, vector<vector<long long>>());
  edgesroot.assign(n, 0);
  sub.assign(n, 1);
  tin.assign(n, 1);
  tout.assign(n, 1);
  num.assign(n, 1);
  dist.assign(n, 0);
  for (long long i = 0; i < n - 1; i++) {
    long long a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    edges.push_back({a, b, c});
    graph[a].push_back({b, c});
  }
  for (long long i = 0; i < n - 1; i++) {
    long long a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    edges.push_back({a, b, c});
    edgesroot[a] = c;
  }
  dfs(0);
  revnum.assign(n, 0);
  init();
  for (long long i = 0; i < n; i++) revnum[num[i]] = i;
  build(0, 0, Size);
  for (long long i = 0; i < q; i++) {
    long long type;
    cin >> type;
    if (type == 1) {
      long long ind, w;
      cin >> ind >> w;
      ind--;
      if (ind < n - 1) {
        addRange(0, 0, Size, num[edges[ind][1]],
                 num[edges[ind][1]] + sub[edges[ind][1]], -edges[ind][2] + w);
      } else {
        addRange(0, 0, Size, num[edges[ind][0]], num[edges[ind][0]] + 1,
                 -edges[ind][2] + w);
        edgesroot[edges[ind][0]] = w;
      }
      edges[ind][2] = w;
    } else {
      long long u, v;
      cin >> u >> v;
      u--;
      v--;
      if (tin[u] <= tin[v] and tout[v] <= tout[u])
        cout << getMin(0, 0, Size, num[v], num[v] + 1) - edgesroot[v] -
                    getMin(0, 0, Size, num[u], num[u] + 1) + edgesroot[u]
             << "\n";
      else
        cout << getMin(0, 0, Size, num[u], num[u] + sub[u]) -
                    getMin(0, 0, Size, num[u], num[u] + 1) + edgesroot[u] -
                    edgesroot[v] + getMin(0, 0, Size, num[v], num[v] + 1)
             << "\n";
    }
  }
}