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 = 200005;
int n, log2n, q, C[N], L[N], R[N], tot = 0, f[N][25], up[N], de2[N];
long long de[N];
struct node {
  long long min, sign;
} a[N * 4];
pair<int, int> E[2 * N];
vector<pair<int, int> > e[N];
void add1(int x, int k) {
  for (; x <= n; x += x & (-x)) de[x] += k;
}
long long ask1(int x) {
  long long res = 0;
  for (; x; x -= x & (-x)) res += de[x];
  return res;
}
void build(int l, int r, int now) {
  if (l == r) {
    a[now].min = ask1(l) + up[C[l]];
    return;
  }
  int mid = (l + r) >> 1;
  build(l, mid, now << 1);
  build(mid + 1, r, now << 1 | 1);
  a[now].min = min(a[now << 1].min, a[now << 1 | 1].min);
}
void update(int l, int r, int now, int k) {
  a[now].min += k;
  a[now].sign += k;
}
void down(int l, int r, int now) {
  int mid = (l + r) >> 1;
  update(l, mid, now << 1, a[now].sign);
  update(mid + 1, r, now << 1 | 1, a[now].sign);
  a[now].sign = 0;
}
void add2(int l, int r, int now, int s, int t, int k) {
  if (s <= l && r <= t) {
    update(l, r, now, k);
    return;
  }
  down(l, r, now);
  int mid = (l + r) >> 1;
  if (s <= mid) add2(l, mid, now << 1, s, t, k);
  if (t > mid) add2(mid + 1, r, now << 1 | 1, s, t, k);
  a[now].min = min(a[now << 1].min, a[now << 1 | 1].min);
}
long long ask2(int l, int r, int now, int s, int t) {
  if (s <= l && r <= t) return a[now].min;
  down(l, r, now);
  int mid = (l + r) >> 1;
  long long res = 0x3f3f3f3f3f3f3f3f;
  if (s <= mid) res = min(ask2(l, mid, now << 1, s, t), res);
  if (t > mid) res = min(ask2(mid + 1, r, now << 1 | 1, s, t), res);
  return res;
}
void dfs1(int u, int fa) {
  f[u][0] = fa;
  C[++tot] = u;
  L[u] = tot;
  for (int i = 0; i < e[u].size(); i++) {
    int v = e[u][i].first;
    if (v == fa) continue;
    dfs1(v, u);
  }
  R[u] = tot;
}
void dfs2(int u, int fa) {
  for (int i = 0; i < e[u].size(); i++) {
    int v = e[u][i].first, w = e[u][i].second;
    if (v == fa) continue;
    de2[v] = de2[u] + 1;
    add1(L[v], w);
    add1(R[v] + 1, -w);
    dfs2(v, u);
  }
}
bool on(int u, int v) {
  swap(u, v);
  long long k = de2[u] - de2[v];
  if (k < 0) return false;
  for (int i = 0; k; i++, k >>= 1)
    if (k & 1) u = f[u][i];
  return (u == v);
}
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> q;
  log2n = log2(n);
  for (int i = 1; i <= 2 * n - 2; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    if (i < n)
      E[i] = {w, v};
    else
      E[i] = {w, u}, up[u] = w;
    if (i >= n) continue;
    e[u].push_back({v, w});
    e[v].push_back({u, w});
  }
  dfs1(1, 0);
  dfs2(1, 0);
  for (int j = 1; j <= log2n; j++)
    for (int i = 1; i <= n; i++) f[i][j] = f[f[i][j - 1]][j - 1];
  build(1, n, 1);
  for (int i = 0; i < q; i++) {
    int c, x, y;
    cin >> c >> x >> y;
    if (c == 1) {
      if (x < n) {
        add1(L[E[x].second], -E[x].first + y);
        add1(R[E[x].second] + 1, E[x].first - y);
        add2(1, n, 1, L[E[x].second], R[E[x].second], -E[x].first + y);
      } else
        add2(1, n, 1, L[E[x].second], L[E[x].second], -E[x].first + y);
      E[x].first = y;
    } else {
      if (on(x, y))
        cout << ask1(L[y]) - ask1(L[x]) << endl;
      else
        cout << ask2(1, n, 1, L[x], R[x]) - ask1(L[x]) + ask1(L[y]) << endl;
    }
  }
  return 0;
}