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 = 1 << 18;
pair<long long, long long> add(pair<long long, long long> a,
                               pair<long long, long long> b) {
  return pair<long long, long long>(a.first + b.first, a.second + b.second);
}
void addto(pair<long long, long long> &a, pair<long long, long long> b) {
  a = add(a, b);
}
int n, q;
vector<int> g[N];
vector<tuple<int, int, int> > E;
int in[N], out[N], dep[N], weight[N << 1];
pair<long long, long long> t[N << 1], lz[N << 1];
void push(int p, int l, int r) {
  if (lz[p] == pair<long long, long long>(0, 0)) return;
  addto(t[p], lz[p]);
  if (l != r) addto(lz[p << 1], lz[p]), addto(lz[p << 1 | 1], lz[p]);
  lz[p] = {0, 0};
}
template <typename T>
void travel(int first, int second, const T &f, int p = 1, int l = 1,
            int r = n) {
  push(p, l, r);
  if (first > r || l > second) return;
  if (first <= l && r <= second) return f(p, l, r);
  int mid = (l + r) >> 1;
  travel(first, second, f, p << 1, l, mid),
      travel(first, second, f, p << 1 | 1, mid + 1, r);
  t[p] = pair<long long, long long>(
      0, min(t[p << 1].second, t[p << 1 | 1].second));
}
void dfs(int u, int p) {
  static int idx = 0;
  dep[u] = dep[p] + 1, in[u] = ++idx;
  for (int v : g[u])
    if (v != u) dfs(v, u);
  out[u] = idx;
}
int main() {
  E.emplace_back(0, 0, 0);
  scanf("%d %d", &n, &q);
  for (int i = 1, a, b, c; i < n; i++) {
    scanf("%d %d %d", &a, &b, &c);
    g[a].emplace_back(b);
    weight[i] = c;
    E.emplace_back(a, b, i);
  }
  dfs(1, 1);
  for (tuple<int, int, int> &e : E) {
    int a, b, idx;
    tie(a, b, idx) = e;
    travel(in[b], out[b], [&](int p, int l, int r) {
      lz[p].first += weight[idx], lz[p].second += weight[idx];
      push(p, l, r);
    });
  }
  for (int i = 1, a, b, c; i < n; i++) {
    scanf("%d %d %d", &a, &b, &c);
    weight[i + n - 1] = c;
    E.emplace_back(b, a, i + n - 1);
    travel(in[a], in[a], [&](int p, int l, int r) {
      lz[p].second += c;
      push(p, l, r);
    });
  }
  for (int i = 1, T, a, b; i <= q; i++) {
    scanf("%d %d %d", &T, &a, &b);
    if (T == 1) {
      int u = get<1>(E[a]);
      travel(in[u], a < n ? out[u] : in[u], [&](int p, int l, int r) {
        if (a < n) lz[p].first += b - weight[a];
        lz[p].second += b - weight[a];
        push(p, l, r);
      });
      weight[a] = b;
    } else {
      long long sum = 0, mn = 1e18;
      travel(in[b], in[b], [&](int p, int l, int r) { sum += t[p].first; });
      travel(in[a], in[a], [&](int p, int l, int r) { sum -= t[p].first; });
      if (in[a] > in[b] || out[b] > out[a])
        travel(in[a], out[a],
               [&](int p, int l, int r) { mn = min(mn, t[p].second); });
      else
        mn = 0;
      printf("%lld\n", sum + mn);
    }
  }
  return 0;
}