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;
void ga(int N, int *A) {
  for (int i(0); i < N; i++) scanf("%d", A + i);
}
struct SA {
  long long A[(1 << 19)], S[(1 << 19)], X[(1 << 19)], M[(1 << 19)];
  int N;
  void ini(int n) {
    N = 1 << (int(log2(n) - (1e-10)) + 1);
    for (int i(0); i < N << 1; i++) A[i] = S[i] = X[i] = 0, M[i] = 1;
  }
  void gt(int u, long long &s, long long &x, long long &m, int b, int e) {
    if (M[u] > X[u])
      m = x = A[u], s = (e - b + 1) * A[u];
    else
      m = M[u] + A[u], x = X[u] + A[u], s = S[u] + A[u] * (e - b + 1);
  }
  void st(int b, int e, long long v = 0) { st(b, e, v, 1, 0, N - 1); }
  void st(int b, int e, long long v, int u, int B, int E) {
    if (B > e || E < b) return;
    if (M[u] > X[u] && B ^ E)
      M[u << 1 | 1] = M[u << 1] = 1, X[u << 1 | 1] = X[u << 1] = 0,
                 A[u << 1 | 1] = A[u << 1] = A[u], A[u] = 0;
    if (b <= B && e >= E) {
      M[u] = 1, X[u] = 0, A[u] = v;
      return;
    }
    long long U, V, W;
    if (A[u])
      ad(B, E, A[u], u << 1, B, (B + E) >> 1),
          ad(B, E, A[u], u << 1 | 1, (B + E) / 2 + 1, E), A[u] = 0;
    st(b, e, v, u << 1, B, (B + E) >> 1),
        st(b, e, v, u << 1 | 1, (B + E) / 2 + 1, E);
    gt(u << 1, S[u], X[u], M[u], B, (B + E) >> 1),
        gt(u << 1 | 1, U, V, W, (B + E) / 2 + 1, E);
    S[u] += U, X[u] = max(X[u], V), M[u] = min(M[u], W);
  }
  void ad(int b, int e, long long v = 1) { ad(b, e, v, 1, 0, N - 1); }
  void ad(int b, int e, long long v, int u, int B, int E) {
    if (B > e || E < b) return;
    if (M[u] > X[u] && B ^ E)
      M[u << 1 | 1] = M[u << 1] = 1, X[u << 1 | 1] = X[u << 1] = 0,
                 A[u << 1 | 1] = A[u << 1] = A[u];
    if (M[u] > X[u]) gt(u, S[u], X[u], M[u], B, E), A[u] = 0;
    if (b <= B && e >= E) {
      A[u] += v;
      return;
    }
    long long U, V, W;
    ad(b, e, v, u << 1, B, (B + E) >> 1),
        ad(b, e, v, u << 1 | 1, (B + E) / 2 + 1, E);
    gt(u << 1, S[u], X[u], M[u], B, (B + E) >> 1),
        gt(u << 1 | 1, U, V, W, (B + E) / 2 + 1, E);
    S[u] += U, X[u] = max(X[u], V), M[u] = min(M[u], W);
  }
  void gt(int b, int e, long long &s, long long &x, long long &m) {
    s = 0, x = -1e18, m = 1e18;
    gt(b, e, 1, 0, N - 1, s, x, m);
  }
  void gt(int b, int e, int u, int B, int E, long long &s, long long &x,
          long long &m) {
    if (B > e || E < b) return;
    long long U = -1e18, V = 1e18, W;
    if (X[u] < M[u] || (b <= B && e >= E))
      gt(u, U, V, W, max(b, B), min(e, E)), s += U, x = max(x, V),
                                                    m = min(m, W);
    else
      gt(b, e, u << 1, B, (B + E) >> 1, s, U, V),
          gt(b, e, u << 1 | 1, (B + E) / 2 + 1, E, s, U, V),
          x = max(x, U + A[u]), m = min(m, V + A[u]),
          s += A[u] * (1 + min(e, E) - max(b, B));
  }
  long long mx(int b, int e) {
    long long u, v, w;
    return gt(b, e, u, v, w), v;
  }
  long long mn(int b, int e) {
    long long u, v, w;
    return gt(b, e, u, v, w), w;
  }
  long long sm(int b, int e) {
    long long u, v, w;
    return gt(b, e, u, v, w), u;
  }
} M;
long long H[1 << 24], W;
struct sS {
  long long *p, *P;
  int N;
  void ini(int n) {
    N = 1 << (int(log2(n) - (1e-10)) + 1), p = H + W, W += N * 2, P = H + W,
    W += N * 2;
    for (int i(0); i < N << 1; i++) p[i] = P[i] = 0;
  }
  void INI(int n, int *D) {
    for (int k(N); k < N + n; k++) P[k] = p[k] = D[k - N];
    for (int i = N - 1; ~i; --i) p[i] = p[i << 1] + p[i << 1 | 1];
  }
  void st(int b, int e, long long v = 1) { st(b, e, v, 1, 0, N - 1); }
  void st(int b, int e, long long v, int u, int B, int E) {
    if (B > e || E < b) return;
    if (b <= B && e >= E) {
      P[u] += v, p[u] += (E - B + 1) * v;
      return;
    }
    st(b, e, v, u << 1, B, (B + E) >> 1),
        st(b, e, v, u << 1 | 1, (B + E) / 2 + 1, E);
    p[u] = p[u << 1 | 1] + p[u << 1] + P[u] * (E - B + 1);
  }
  long long gt(int b, int e) { return gt(b, e, 1, 0, N - 1); }
  long long gt(int b, int e, int u, int B, int E) {
    if (B > e || E < b) return 0;
    if (b <= B && e >= E) return p[u];
    return gt(b, e, u << 1, B, (B + E) >> 1) +
           gt(b, e, u << 1 | 1, (B + E) / 2 + 1, E) +
           (min(e, E) - max(b, B) + 1) * P[u];
  }
} G[(1 << 19)];
vector<int> g[(1 << 19)];
int D[(1 << 19)], P[(1 << 19)], R, I[(1 << 19)], T[(1 << 19)], C[(1 << 19)], O,
    F[(1 << 19)];
int dfs(int u, int d, int p) {
  int w, S(1), b = -1;
  D[u] = d, P[u] = p, F[u] = -1;
  for (auto &h : g[u])
    if (h ^ p) {
      S += w = dfs(h, d + 1, u);
      if (w > b) b = w, F[u] = h;
    }
  return S;
}
void hld(int u, int B, int c) {
  for (auto &h : g[u])
    if (h ^ P[u]) {
      if (h ^ F[u])
        hld(h, 0, O++);
      else
        hld(h, B + 1, c);
    }
  if (!~F[u]) G[c].ini(B + 1);
  if (!B) T[c] = u;
  I[u] = B, C[u] = c;
  if (g[u].empty()) G[c].ini(B + 1);
}
void ini(int r = 0) { dfs(R = r, 0, r), W = 0, O = 1, hld(R, 0, 0); }
void clr() {
  W = 0;
  for (int i(0); i < (1 << 19); i++) g[i].clear();
}
int lca(int a, int b) {
  if (C[a] == C[b]) return D[a] < D[b] ? a : b;
  return D[T[C[a]]] < D[T[C[b]]] ? lca(P[T[C[b]]], a) : lca(P[T[C[a]]], b);
}
long long LCA(int a, int b) {
  if (C[a] == C[b]) return G[C[a]].gt(min(I[a], I[b]), max(I[a], I[b]));
  return D[T[C[a]]] < D[T[C[b]]] ? (G[C[b]].gt(0, I[b]) + LCA(P[T[C[b]]], a))
                                 : (LCA(P[T[C[a]]], b) + G[C[a]].gt(0, I[a]));
}
int N, Q, A[(1 << 19)], B[(1 << 19)], l[(1 << 19)], a, b, c, r[(1 << 19)],
    Z[(1 << 19)], E[(1 << 19)], f[(1 << 19)], t[(1 << 19)];
void ed(int u, int &l) {
  f[u] = l, E[l++] = u;
  for (auto &h : g[u]) ed(h, l);
  t[u] = l - 1;
}
int main(void) {
  scanf("%d%d", &N, &Q), clr(), M.ini(N), M.st(0, N - 1, 0);
  for (int i(0); i < N - 1; i++)
    scanf("%d%d%d", &a, &b, &c), A[i] = --a, B[i] = --b, l[i] = c, Z[b] = c,
                                 g[a].push_back(b);
  for (int i(0); i < N - 1; i++)
    scanf("%d%d%d", &a, &b, &c), A[i + N - 1] = --a, B[i + N - 1] = --b,
                                           l[i + N - 1] = c, r[a] = c;
  ini(), ed(0, a = 0);
  for (int k(1); k < N; k++) G[C[k]].st(I[k], I[k], Z[k]);
  for (int i(0); i < N; i++) M.ad(f[i], f[i], r[i] + LCA(0, i));
  for (int i(0); i < Q; i++) {
    scanf("%d%d%d", &a, &b, &c);
    if (a == 1) {
      if (--b < N - 1)
        a = B[b], M.ad(f[a], t[a], c - Z[a]), G[C[a]].st(I[a], I[a], -Z[a]),
        G[C[a]].st(I[a], I[a], Z[a] = c);
      else
        a = A[b], M.ad(f[a], f[a], c - r[a]), r[a] = c;
    } else {
      --b, --c;
      if (lca(b, c) == b)
        printf("%lld\n", LCA(b, c) - Z[b]);
      else
        printf("%lld\n", LCA(c, 0) + M.mn(f[b], t[b]) - LCA(b, 0));
    }
  }
  return 0;
}