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 MAXN = 200005;
const int MAXLOGN = 19;
const int MAXSEG = 1 << 19;
const long long INFTY = 1LL << 60;
int N, Q;
pair<pair<int, int>, int> E[2 * MAXN];
vector<pair<int, int> > adj[MAXN];
long long D[MAXN];
long long J[MAXN];
int R[MAXN][2], ind = 0;
int order[MAXN];
int jmp[MAXN][MAXLOGN];
int dep[MAXN];
long long seg[MAXSEG];
long long lazy[MAXSEG];
void process() {
  for (int j = 1; j < MAXLOGN; j++)
    for (int i = 0; i < N; i++) jmp[i][j] = jmp[jmp[i][j - 1]][j - 1];
}
int query(int a, int b) {
  if (dep[a] > dep[b]) swap(a, b);
  for (int i = MAXLOGN - 1; i >= 0; i--)
    if (dep[jmp[b][i]] >= dep[a]) b = jmp[b][i];
  if (a == b) return a;
  for (int i = MAXLOGN - 1; i >= 0; i--)
    if (jmp[a][i] != jmp[b][i]) {
      a = jmp[a][i];
      b = jmp[b][i];
    }
  return jmp[a][0];
}
void dfs(int cur, int prev) {
  R[cur][0] = ++ind;
  order[ind] = cur;
  for (int i = 0; i < adj[cur].size(); i++) {
    int next = adj[cur][i].first, w = adj[cur][i].second;
    if (next == prev) continue;
    D[next] = D[cur] + w;
    dep[next] = dep[cur] + 1;
    jmp[next][0] = cur;
    dfs(next, cur);
  }
  R[cur][1] = ind;
}
void build_tree(int node, int left, int right) {
  if (left == right) {
    seg[node] = D[order[left]] + J[order[left]];
    return;
  }
  int mid = (left + right) / 2;
  build_tree(2 * node, left, mid);
  build_tree(2 * node + 1, mid + 1, right);
  seg[node] = min(seg[2 * node], seg[2 * node + 1]);
}
void down(int node) {
  if (lazy[node] != 0) {
    seg[2 * node] += lazy[node];
    seg[2 * node + 1] += lazy[node];
    lazy[2 * node] += lazy[node];
    lazy[2 * node + 1] += lazy[node];
    lazy[node] = 0;
  }
}
void update(int node, int left, int right, int ql, int qr, long long val) {
  if (left > right || ql > qr || qr < left || right < ql) return;
  if (ql <= left && right <= qr) {
    seg[node] += val;
    lazy[node] += val;
    return;
  }
  down(node);
  int mid = (left + right) / 2;
  update(2 * node, left, mid, ql, qr, val);
  update(2 * node + 1, mid + 1, right, ql, qr, val);
  seg[node] = min(seg[2 * node], seg[2 * node + 1]);
}
long long query(int node, int left, int right, int ql, int qr) {
  if (left > right || ql > qr || qr < left || right < ql) return INFTY;
  if (ql <= left && right <= qr) return seg[node];
  down(node);
  int mid = (left + right) / 2;
  return min(query(2 * node, left, mid, ql, qr),
             query(2 * node + 1, mid + 1, right, ql, qr));
}
int main() {
  scanf("%d %d", &N, &Q);
  for (int i = 0; i < 2 * N - 2; i++) {
    scanf("%d %d %d", &E[i].first.first, &E[i].first.second, &E[i].second);
    E[i].first.first--;
    E[i].first.second--;
    if (i < N - 1) {
      adj[E[i].first.first].push_back(
          make_pair(E[i].first.second, E[i].second));
      adj[E[i].first.second].push_back(
          make_pair(E[i].first.first, E[i].second));
    } else
      J[E[i].first.first] = E[i].second;
  }
  dfs(0, -1);
  process();
  build_tree(1, 1, N);
  for (int i = 0, a, b, c; i < Q; i++) {
    scanf("%d %d %d", &a, &b, &c);
    if (a == 1) {
      b--;
      if (b < N - 1) {
        long long val = c - E[b].second;
        update(1, 1, N, R[E[b].first.second][0], R[E[b].first.second][1], val);
        E[b].second = c;
      } else {
        long long val = c - E[b].second;
        update(1, 1, N, R[E[b].first.first][0], R[E[b].first.first][0], val);
        E[b].second = c;
        J[E[b].first.first] = c;
      }
    } else {
      b--, c--;
      long long distb = query(1, 1, N, R[b][0], R[b][0]) - J[b];
      long long distc = query(1, 1, N, R[c][0], R[c][0]) - J[c];
      long long cur = query(1, 1, N, R[b][0], R[b][1]) - distb + distc;
      int lca = query(b, c);
      if (lca == b) cur = min(cur, distc - distb);
      printf("%I64d\n", cur);
    }
  }
  return 0;
}