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 long long mod = 1e9 + 7ll;
struct p {
  long long add, mem;
  p() {}
  p(const long long& add_, const long long& mem_) {
    this->add = add_, this->mem = mem_;
  }
  long long sum() { return this->add + this->mem; }
};
class Seg {
 public:
  p t[200004 * 4];
  Seg() { memset(t, 0, sizeof t); }
  void update(int v) {
    t[v].mem =
        min(t[v * 2].mem + t[v * 2].add, t[v * 2 + 1].mem + t[v * 2 + 1].add);
  }
  void push(int v) {
    t[v * 2].add += t[v].add;
    t[v * 2 + 1].add += t[v].add;
    t[v].mem += t[v].add;
    t[v].add = 0;
  }
  void add(int v, const int& tl, const int& tr, const int& l, const int& r,
           const long long& c) {
    if (l <= tl && r >= tr) {
      t[v].add += c;
      return;
    }
    int m = (tl + tr) >> 1;
    push(v);
    if (l <= m) add(v * 2, tl, m, l, r, c);
    if (r > m) add(v * 2 + 1, m + 1, tr, l, r, c);
    update(v);
  }
  long long query(int v, const int& tl, const int& tr, const int& l,
                  const int& r) {
    if (l <= tl && r >= tr) return t[v].sum();
    int m = (tl + tr) >> 1;
    push(v);
    long long ret = 100000000000005;
    if (l <= m) ret = min(ret, query(v * 2, tl, m, l, r));
    if (r > m) ret = min(ret, query(v * 2 + 1, m + 1, tr, l, r));
    return ret;
  }
};
int len;
Seg* S;
vector<pair<int, long long>> e[200004];
int n, q;
long long f[200004];
int be[200004], en[200004];
int tot;
int a[200004 * 2], b[200004 * 2], c[200004 * 2];
void dfs(int x, long long l) {
  tot++;
  be[x] = tot;
  S->add(1, 1, n, tot, tot, l + f[x]);
  for (auto p : e[x]) dfs(p.first, l + p.second);
  en[x] = tot;
}
long long path(int x) { return S->query(1, 1, n, be[x], be[x]) - f[x]; }
int main() {
  S = new Seg();
  scanf("%d%d", &n, &q);
  for (int i = 1; i <= n - 1; ++i) {
    scanf("%d%d%d", &a[i], &b[i], &c[i]);
    e[a[i]].push_back({b[i], c[i]});
  }
  for (int i = n; i <= 2 * n - 2; ++i) {
    scanf("%d%d%d", &a[i], &b[i], &c[i]);
    f[a[i]] = c[i];
  }
  tot = 0;
  dfs(1, 0);
  for (int i = 1; i <= q; ++i) {
    int op, x, y;
    scanf("%d%d%d", &op, &x, &y);
    if (op == 1) {
      if (x <= n - 1)
        S->add(1, 1, n, be[b[x]], en[b[x]], y - c[x]);
      else {
        S->add(1, 1, n, be[a[x]], be[a[x]], y - c[x]);
        f[a[x]] = y;
      }
      c[x] = y;
    } else {
      long long px = path(x), py = path(y);
      if (be[y] >= be[x] && en[y] <= en[x])
        printf("%I64d\n", py - px);
      else
        printf("%I64d\n", S->query(1, 1, n, be[x], en[x]) - px + py);
    }
  }
}