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;
namespace IO {
const int MAXIOSIZE = 1 << 24 | 1;
unsigned char buf[MAXIOSIZE], *p1, *p2;
template <typename T>
void read(T& x) {
  x = 0;
  char ch =
      (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 24, stdin), p1 == p2)
           ? EOF
           : *p1++);
  bool flg = false;
  for (; ch < '0' || '9' < ch;
       ch = (p1 == p2 &&
                     (p2 = (p1 = buf) + fread(buf, 1, 1 << 24, stdin), p1 == p2)
                 ? EOF
                 : *p1++))
    if (ch == '-') flg |= true;
  for (; '0' <= ch && ch <= '9';
       ch = (p1 == p2 &&
                     (p2 = (p1 = buf) + fread(buf, 1, 1 << 24, stdin), p1 == p2)
                 ? EOF
                 : *p1++))
    x = x * 10 + ch - '0';
  flg ? x = -x : 0;
}
template <typename T>
void out(const T& x) {
  if (x > 9) out(x / 10);
  putchar(x % 10 + '0');
}
template <typename T>
inline void write(const T& x, const char& ed = ' ') {
  if (x < 0)
    putchar('-'), out(-x);
  else
    out(x);
  putchar(ed);
}
}  // namespace IO
const int MAXN = 2e5 + 10;
int n, q;
int head[MAXN], ecnt;
struct Edge {
  int nxt, to, w;
} e[MAXN];
void add(int u, int v, int w) {
  e[++ecnt].nxt = head[u], e[ecnt].to = v, e[ecnt].w = w, head[u] = ecnt;
}
int dfsclock, dtp[MAXN];
struct Vertix {
  int sz, fa, dfn, w;
} vtx[MAXN];
int edgenum[MAXN], edgenum2[MAXN << 1];
;
long long w2[MAXN];
void dfs(int u, int fr) {
  vtx[u].sz = 1, vtx[u].fa = fr;
  dtp[vtx[u].dfn = ++dfsclock] = u;
  for (int _ = head[u], v = e[_].to; _; _ = e[_].nxt, v = e[_].to) {
    vtx[v].w = e[_].w, edgenum[_] = v;
    dfs(v, u);
    vtx[u].sz += vtx[v].sz;
  }
}
struct Segment_tree {
  struct Node {
    long long val, add, mnval;
  } t[MAXN << 2];
  void pushdown(int k) {
    long long& d = t[k].add;
    t[k << 1].add += d, t[k << 1 | 1].add += d;
    t[k << 1].val += d, t[k << 1 | 1].val += d;
    t[k << 1].mnval += d, t[k << 1 | 1].mnval += d;
    d = 0;
  }
  void pushup(int k) {
    if (t[k << 1].mnval < t[k << 1 | 1].mnval)
      t[k].mnval = t[k << 1].mnval;
    else
      t[k].mnval = t[k << 1 | 1].mnval;
  }
  void modify(int k, int l, int r, int ql, int qr, long long val) {
    if (ql <= l && r <= qr)
      return t[k].add += val, t[k].val += val, t[k].mnval += val, void();
    pushdown(k);
    if (ql <= ((l + r) >> 1)) modify(k << 1, l, ((l + r) >> 1), ql, qr, val);
    if (qr > ((l + r) >> 1))
      modify(k << 1 | 1, ((l + r) >> 1) + 1, r, ql, qr, val);
    pushup(k);
  }
  long long query(int k, int l, int r, int pos) {
    if (l == r) return t[k].val;
    pushdown(k);
    if (pos <= ((l + r) >> 1))
      return query(k << 1, l, ((l + r) >> 1), pos);
    else
      return query(k << 1 | 1, ((l + r) >> 1) + 1, r, pos);
  }
  long long mnval(int k, int l, int r, int ql, int qr) {
    if (ql <= l && r <= qr) return t[k].mnval;
    pushdown(k);
    long long res = LONG_LONG_MAX;
    if (ql <= ((l + r) >> 1))
      res = min(res, mnval(k << 1, l, ((l + r) >> 1), ql, qr));
    if (qr > ((l + r) >> 1))
      res = min(res, mnval(k << 1 | 1, ((l + r) >> 1) + 1, r, ql, qr));
    return res;
  }
  void modify2(int k, int l, int r, int pos, long long val) {
    if (l == r) return t[k].mnval += val, void();
    pushdown(k);
    if (pos <= ((l + r) >> 1))
      modify2(k << 1, l, ((l + r) >> 1), pos, val);
    else
      modify2(k << 1 | 1, ((l + r) >> 1) + 1, r, pos, val);
    pushup(k);
  }
} sgt;
int main() {
  IO::read(n), IO::read(q);
  for (int i = (1), iend = (n - 1); i <= iend; ++i) {
    int u, v, w;
    IO::read(u), IO::read(v), IO::read(w);
    add(u, v, w);
  }
  dfs(1, 0);
  for (int i = (1), iend = (n - 1); i <= iend; ++i) {
    int idx, tt, w;
    IO::read(idx), IO::read(tt), IO::read(w);
    w2[idx] = w, edgenum2[n - 1 + i] = idx;
    sgt.modify2(1, 1, n, vtx[idx].dfn, w);
  }
  for (int i = (1), iend = (n); i <= iend; ++i) {
    sgt.modify(1, 1, n, vtx[i].dfn, vtx[i].dfn + vtx[i].sz - 1, vtx[i].w);
  }
  for (int i = (1), iend = (q); i <= iend; ++i) {
    int opt;
    IO::read(opt);
    if (opt == 1) {
      int idx, w;
      IO::read(idx), IO::read(w);
      if (idx <= n - 1) {
        int u = edgenum[idx];
        sgt.modify(1, 1, n, vtx[u].dfn, vtx[u].dfn + vtx[u].sz - 1, -vtx[u].w);
        vtx[u].w = w;
        sgt.modify(1, 1, n, vtx[u].dfn, vtx[u].dfn + vtx[u].sz - 1, vtx[u].w);
      } else {
        int u = edgenum2[idx];
        sgt.modify2(1, 1, n, vtx[u].dfn, -w2[u]);
        w2[u] = w;
        sgt.modify2(1, 1, n, vtx[u].dfn, w2[u]);
      }
    } else {
      int u, v;
      IO::read(u), IO::read(v);
      if (vtx[u].dfn <= vtx[v].dfn &&
          vtx[v].dfn <= vtx[u].dfn + vtx[u].sz - 1) {
        IO::write(
            sgt.query(1, 1, n, vtx[v].dfn) - sgt.query(1, 1, n, vtx[u].dfn),
            '\n');
      } else {
        long long sum1 =
            sgt.mnval(1, 1, n, vtx[u].dfn, vtx[u].dfn + vtx[u].sz - 1);
        IO::write(sum1 - sgt.query(1, 1, n, vtx[u].dfn) +
                      sgt.query(1, 1, n, vtx[v].dfn),
                  '\n');
      }
    }
  }
  return 0;
}