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;
template <typename T>
void chkmax(T &x, T y) {
  x = x > y ? x : y;
}
template <typename T>
void chkmin(T &x, T y) {
  x = x > y ? y : x;
}
const int INF = 2139062143;
template <typename T>
void read(T &x) {
  x = 0;
  bool f = 1;
  char ch;
  do {
    ch = getchar();
    if (ch == '-') f = 0;
  } while (ch > '9' || ch < '0');
  do {
    x = x * 10 + ch - '0';
    ch = getchar();
  } while (ch >= '0' && ch <= '9');
  x = f ? x : -x;
}
template <typename T>
void write(T x) {
  if (x < 0) x = ~x + 1, putchar('-');
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
const int N = 2e5 + 7;
struct EDGE {
  int w, to, nxt;
} edge[N];
int n, q, E, cnt, num, W[N], w[N], e[N], d[N], sz[N], dis[N], dfn[N], head[N];
pair<int, int> p[N << 1];
inline void addedge(int u, int v, int w) {
  edge[++E].to = v;
  edge[E].w = w;
  edge[E].nxt = head[u];
  head[u] = E;
}
inline void dfs(int u, int f) {
  sz[u] = 1;
  dfn[u] = ++cnt;
  w[cnt] = dis[u];
  e[cnt] = d[u];
  for (int i = head[u]; i; i = edge[i].nxt) {
    int v = edge[i].to, w = edge[i].w;
    if (v == f) continue;
    dis[v] = dis[u] + w;
    dfs(v, u);
    sz[u] += sz[v];
  }
}
struct Segment_Tree {
  int l, r, tag, dat, sum;
} t[N << 2];
inline void push(int p, int k) {
  t[p].dat = (t[p].dat + k);
  t[p].sum = (t[p].sum + k);
  t[p].tag = (t[p].tag + k);
}
inline void pushdown(int p) {
  push((p << 1), t[p].tag);
  push((p << 1 | 1), t[p].tag);
  t[p].tag = 0;
}
inline void build(int p, int l, int r) {
  t[p].l = l;
  t[p].r = r;
  if (l == r) {
    t[p].dat = w[l];
    t[p].sum = w[l] + e[l];
    return;
  }
  int mid = (t[p].l + t[p].r) >> 1;
  build((p << 1), l, mid);
  build((p << 1 | 1), mid + 1, r);
  t[p].dat = min(t[(p << 1)].dat, t[(p << 1 | 1)].dat);
  t[p].sum = min(t[(p << 1)].sum, t[(p << 1 | 1)].sum);
}
inline void change(int p, int pos, int k) {
  if (t[p].l == t[p].r) {
    t[p].sum = (t[p].dat + k);
    return;
  }
  int mid = (t[p].l + t[p].r) >> 1;
  pushdown(p);
  if (pos <= mid)
    change((p << 1), pos, k);
  else
    change((p << 1 | 1), pos, k);
  t[p].sum = min(t[(p << 1)].sum, t[(p << 1 | 1)].sum);
  t[p].dat = min(t[(p << 1)].dat, t[(p << 1 | 1)].dat);
}
inline void modify(int p, int l, int r, int k) {
  if (l <= t[p].l && t[p].r <= r) {
    push(p, k);
    return;
  }
  int mid = (t[p].l + t[p].r) >> 1;
  pushdown(p);
  if (l <= mid) modify((p << 1), l, r, k);
  if (r > mid) modify((p << 1 | 1), l, r, k);
  t[p].dat = min(t[(p << 1)].dat, t[(p << 1 | 1)].dat);
  t[p].sum = min(t[(p << 1)].sum, t[(p << 1 | 1)].sum);
}
inline int query(int p, int l, int r) {
  if (l <= t[p].l && t[p].r <= r) return t[p].sum;
  int mid = (t[p].l + t[p].r) >> 1, ans = INF;
  pushdown(p);
  if (l <= mid) ans = min(ans, query((p << 1), l, r));
  if (r > mid) ans = min(ans, query((p << 1 | 1), l, r));
  return ans;
}
inline int ask(int p, int pos) {
  if (t[p].l == t[p].r) return t[p].dat;
  int mid = (t[p].l + t[p].r) >> 1;
  pushdown(p);
  if (pos <= mid)
    return ask((p << 1), pos);
  else
    return ask((p << 1 | 1), pos);
}
int main() {
  read(n);
  read(q);
  for (int i = 1, u, v, w; i < n; i++) {
    read(u);
    read(v);
    read(w);
    addedge(u, v, w);
    p[++num] = make_pair(u, v);
    W[i] = w;
  }
  for (int i = 1, u, v, w; i < n; i++) {
    read(u);
    read(v);
    read(w);
    d[u] = w;
    p[++num] = make_pair(u, v);
  }
  dfs(1, 0);
  build(1, 1, n);
  for (int i = 1, opt, a, b; i <= q; i++) {
    read(opt);
    if (opt == 1) {
      read(a);
      read(b);
      if (a <= n - 1) {
        int u = p[a].second;
        modify(1, dfn[u], dfn[u] + sz[u] - 1, b - W[a]);
        W[a] = b;
      } else {
        int u = p[a].first;
        change(1, dfn[u], b);
      }
    } else {
      read(a);
      read(b);
      int ans = query(1, dfn[a], dfn[a] + sz[a] - 1) - ask(1, dfn[a]) +
                ask(1, dfn[b]);
      if (dfn[a] <= dfn[b] && dfn[b] <= dfn[a] + sz[a] - 1) {
        ans = min(ans, ask(1, dfn[b]) - ask(1, dfn[a]));
      }
      printf("%d\n", ans);
    }
  }
  return 0;
}