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 = 2e5 + 5;
const int D = 25;
struct Edge {
  int u, v, w, nex;
} edges[N];
int head[N], etot;
void addEdge(int u, int v, int w) {
  edges[++etot] = Edge{u, v, w, head[u]};
  head[u] = etot;
}
int dep[N], L[N], R[N], id[N];
long long dis[N];
int rt[N][D];
int dfs_clock;
int a[N], nd[N << 1];
int n, q;
void DFS(int u, int fa) {
  L[u] = ++dfs_clock;
  id[dfs_clock] = u;
  rt[u][0] = fa;
  for (int i = head[u]; i; i = edges[i].nex) {
    Edge &e = edges[i];
    if (e.v == fa) continue;
    dep[e.v] = dep[u] + 1;
    dis[e.v] = dis[u] + e.w;
    DFS(e.v, u);
  }
  R[u] = dfs_clock;
}
void initLCA() {
  for (int j = 1; j < D; ++j) {
    for (int i = 1; i <= n; ++i) {
      rt[i][j] = !rt[i][j - 1] ? 0 : rt[rt[i][j - 1]][j - 1];
    }
  }
}
int LCA(int u, int v) {
  if (dep[u] < dep[v]) swap(u, v);
  for (int i = 0; i < D; ++i) {
    if ((dep[u] - dep[v]) >> i & 1) u = rt[u][i];
  }
  if (u == v) return u;
  for (int i = D - 1; i >= 0; --i) {
    if (rt[u][i] != rt[v][i]) {
      u = rt[u][i];
      v = rt[v][i];
    }
  }
  return rt[u][0];
}
long long v[N << 2], tag[N << 2];
void up(int o) { v[o] = min(v[o << 1], v[o << 1 | 1]); }
void build(int o, int l, int r) {
  if (l == r) {
    v[o] = dis[id[l]] + a[id[l]];
    return;
  }
  int mid = l + r >> 1;
  build(o << 1, l, mid);
  build(o << 1 | 1, mid + 1, r);
  up(o);
}
void down(int o) {
  if (tag[o]) {
    tag[o << 1] += tag[o];
    v[o << 1] += tag[o];
    tag[o << 1 | 1] += tag[o];
    v[o << 1 | 1] += tag[o];
    tag[o] = 0;
  }
}
int ql, qr;
void modify(int o, int l, int r, long long x) {
  if (ql > r || qr < l) return;
  if (ql <= l && r <= qr) {
    tag[o] += x;
    v[o] += x;
    return;
  }
  down(o);
  int mid = l + r >> 1;
  modify(o << 1, l, mid, x);
  modify(o << 1 | 1, mid + 1, r, x);
  up(o);
}
long long query(int o, int l, int r) {
  if (ql <= l && r <= qr) return v[o];
  down(o);
  int mid = l + r >> 1;
  long long ret = (long long)1e18;
  if (ql <= mid) ret = min(ret, query(o << 1, l, mid));
  if (qr > mid) ret = min(ret, query(o << 1 | 1, mid + 1, r));
  return ret;
}
void update(int i, int w) {
  Edge &e = edges[i];
  ql = qr = L[e.u];
  long long du = query(1, 1, n) - a[e.u];
  ql = qr = L[e.v];
  long long dv = query(1, 1, n) - a[e.v];
  qr = R[e.v];
  modify(1, 1, n, w - (dv - du));
}
long long ask(int u, int v) {
  if (u == v) return 0;
  int lca = LCA(u, v);
  ql = qr = L[v];
  long long dv = query(1, 1, n) - a[v];
  ql = qr = L[u];
  long long du = query(1, 1, n) - a[u];
  if (u == lca) {
    return dv - du;
  } else {
    ql = L[u];
    qr = R[u];
    long long t = query(1, 1, n);
    return t - du + dv;
  }
}
int main() {
  scanf("%d%d", &n, &q);
  for (int i = 1; i < n; ++i) {
    int u, v, w;
    scanf("%d%d%d", &u, &v, &w);
    addEdge(u, v, w);
  }
  for (int i = n; i < 2 * n - 1; ++i) {
    int u, v, w;
    scanf("%d%d%d", &u, &v, &w);
    a[u] = w;
    nd[i] = u;
  }
  DFS(1, 0);
  initLCA();
  build(1, 1, n);
  for (int i = 1; i <= q; ++i) {
    int op, x, y;
    scanf("%d%d%d", &op, &x, &y);
    if (op == 1) {
      if (x >= n) {
        ql = qr = L[nd[x]];
        modify(1, 1, n, y - a[nd[x]]);
        a[nd[x]] = y;
      } else
        update(x, y);
    } else {
      printf("%I64d\n", ask(x, y));
    }
  }
  return 0;
}