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;
struct segt {
  long long value, lz;
};
struct edge {
  int from, to;
  long long w;
};
edge edg[524312];
segt tree1[524312], tree2[524312];
int dfsord[524312 >> 1];
int subsz[524312 >> 1];
int height[524312 >> 1];
long long backward[524312 >> 1];
vector<pair<int, long long> > g[524312 >> 1];
long long depth[524312 >> 1];
int k = 1;
int parent[524312 >> 1][19];
int remap[524312 >> 1];
void dfs(int v, int pre, long long w, int ht) {
  parent[v][0] = pre;
  int i;
  dfsord[v] = k++;
  remap[k - 1] = v;
  subsz[v] = 1;
  height[v] = ht;
  depth[v] = w;
  for (i = 1; i <= 18; i++) {
    parent[v][i] = parent[parent[v][i - 1]][i - 1];
  }
  for (auto p : g[v]) {
    int nv = p.first;
    if (nv != pre) {
      dfs(nv, v, w + p.second, ht + 1);
      subsz[v] += subsz[nv];
    }
  }
}
int LCA(int u, int v) {
  if (height[u] < height[v]) {
    swap(u, v);
  }
  int i;
  for (i = 18; i >= 0; i--) {
    if (height[u] >= (1 << i) + height[v]) {
      u = parent[u][i];
    }
  }
  if (u == v) return u;
  for (i = 18; i >= 0; i--) {
    if (parent[u][i] != parent[v][i]) {
      u = parent[u][i];
      v = parent[v][i];
    }
  }
  return parent[u][0];
}
void pushdown(segt tree[], int l, int r, int index) {
  if (l > r) return;
  if (tree[index].lz) {
    if (l != r) {
      tree[index * 2].value += tree[index].lz;
      tree[index * 2 + 1].value += tree[index].lz;
      tree[index * 2].lz += tree[index].lz;
      tree[index * 2 + 1].lz += tree[index].lz;
    }
    tree[index].lz = 0;
  }
}
void update(segt tree[], int start, int end, int l, int r, int index,
            long long val) {
  if (start > end || l > r) return;
  pushdown(tree, l, r, index);
  if (start > r || l > end) return;
  if (start <= l && r <= end) {
    tree[index].value += val;
    tree[index].lz += val;
    return;
  }
  int mid = l + (r - l) / 2;
  update(tree, start, end, l, mid, index * 2, val);
  update(tree, start, end, mid + 1, r, index * 2 + 1, val);
  tree[index].value = min(tree[index * 2].value, tree[index * 2 + 1].value);
}
long long query(segt tree[], int start, int end, int l, int r, int index) {
  if (start > end || l > r) return 10000000000000ll;
  pushdown(tree, l, r, index);
  if (start > r || l > end) return 10000000000000ll;
  if (start <= l && r <= end) return tree[index].value;
  int mid = l + (r - l) / 2;
  if (end <= mid) {
    return query(tree, start, end, l, mid, index * 2);
  }
  if (start >= mid + 1) {
    return query(tree, start, end, mid + 1, r, index * 2 + 1);
  }
  return min(query(tree, start, end, l, mid, index * 2),
             query(tree, start, end, mid + 1, r, index * 2 + 1));
}
void build(int l, int r, int index) {
  if (l > r) return;
  if (l == r) {
    tree1[index].value = depth[remap[l]];
    tree2[index].value = backward[remap[l]] + tree1[index].value;
    return;
  }
  int mid = l + (r - l) / 2;
  build(l, mid, index * 2);
  build(mid + 1, r, index * 2 + 1);
  tree1[index].value = min(tree1[index * 2].value, tree1[index * 2 + 1].value);
  tree2[index].value = min(tree2[index * 2].value, tree2[index * 2 + 1].value);
}
int n;
int main() {
  int m;
  scanf("%d%d", &n, &m);
  int i;
  for (i = 1; i <= 2 * n - 2; i++) {
    scanf("%d%d%lld", &edg[i].from, &edg[i].to, &edg[i].w);
    if (i <= n - 1) {
      g[edg[i].from].emplace_back(edg[i].to, edg[i].w);
    } else {
      backward[edg[i].from] = edg[i].w;
    }
  }
  dfs(1, 0, 0, 0);
  build(1, n, 1);
  while (m > 0) {
    int tp;
    scanf("%d", &tp);
    if (tp == 1) {
      int id;
      long long wei;
      scanf("%d%lld", &id, &wei);
      if (id <= n - 1) {
        update(tree1, dfsord[edg[id].to],
               dfsord[edg[id].to] + subsz[edg[id].to] - 1, 1, n, 1,
               wei - edg[id].w);
        update(tree2, dfsord[edg[id].to],
               dfsord[edg[id].to] + subsz[edg[id].to] - 1, 1, n, 1,
               wei - edg[id].w);
        edg[id].w = wei;
      } else {
        update(tree2, dfsord[edg[id].from], dfsord[edg[id].from], 1, n, 1,
               wei - edg[id].w);
        edg[id].w = wei;
      }
    } else {
      int u, v;
      scanf("%d%d", &u, &v);
      int anc = LCA(u, v);
      if (anc == u) {
        printf("%lld\n", query(tree1, dfsord[v], dfsord[v], 1, n, 1) -
                             query(tree1, dfsord[u], dfsord[u], 1, n, 1));
      } else {
        printf("%lld\n",
               query(tree2, dfsord[u], dfsord[u] + subsz[u] - 1, 1, n, 1) -
                   query(tree1, dfsord[u], dfsord[u], 1, n, 1) +
                   query(tree1, dfsord[v], dfsord[v], 1, n, 1));
      }
    }
    m--;
  }
  return 0;
}