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 Tp>
inline void read(Tp &x) {
  x = 0;
  bool neg = false;
  char c = getchar();
  for (; !isdigit(c); c = getchar()) {
    if (c == '-') {
      neg = true;
    }
  }
  for (; isdigit(c); c = getchar()) {
    x = x * 10 + c - '0';
  }
  if (neg) {
    x = -x;
  }
}
const int N = 200000 + 5;
const long long INF = 0x3f3f3f3f3f3f3f3f;
int n, Q;
int head[N], E = 0;
struct Edge {
  int to, next, w;
} e[N];
inline void addEdge(int u, int v, int w) {
  e[++E] = (Edge){v, head[u], w};
  head[u] = E;
}
int from[N], back[N], node[N];
int in[N], out[N], tim = 0;
int ord[N];
long long dis[N];
void dfs(int u) {
  in[u] = ++tim;
  ord[tim] = u;
  for (int i = head[u], v; v = e[i].to, i; i = e[i].next) {
    dis[v] = dis[u] + e[i].w;
    dfs(v);
  }
  out[u] = tim;
}
namespace Seg {
const int N = ::N * 4 * 2;
long long a[N], tag[N];
inline void pushDown(int u) {
  if (tag[u] == 0) {
    return;
  }
  a[((u) << 1)] += tag[u];
  tag[((u) << 1)] += tag[u];
  a[((u) << 1 | 1)] += tag[u];
  tag[((u) << 1 | 1)] += tag[u];
  tag[u] = 0;
}
void build(int u, int l, int r) {
  if (l == r) {
    a[u] = dis[ord[l]] + back[ord[l]];
    return;
  }
  int mid = (l + r) >> 1;
  build(((u) << 1), l, mid);
  build(((u) << 1 | 1), mid + 1, r);
  a[u] = std::min(a[((u) << 1)], a[((u) << 1 | 1)]);
}
void update(int u, int l, int r, int ul, int ur, int x) {
  if (ul <= l && r <= ur) {
    a[u] += x;
    tag[u] += x;
    return;
  }
  pushDown(u);
  int mid = (l + r) >> 1;
  if (ul <= mid) {
    update(((u) << 1), l, mid, ul, ur, x);
  }
  if (mid < ur) {
    update(((u) << 1 | 1), mid + 1, r, ul, ur, x);
  }
  a[u] = std::min(a[((u) << 1)], a[((u) << 1 | 1)]);
}
long long query(int u, int l, int r, int ql, int qr) {
  if (ql <= l && r <= qr) {
    return a[u];
  }
  pushDown(u);
  int mid = (l + r) >> 1;
  long long res = INF;
  if (ql <= mid) {
    res = query(((u) << 1), l, mid, ql, qr);
  }
  if (mid < qr) {
    res = std::min(res, query(((u) << 1 | 1), mid + 1, r, ql, qr));
  }
  return res;
}
inline long long get(int u) { return query(1, 1, n, in[u], in[u]); }
}  // namespace Seg
int main() {
  read(n), read(Q);
  for (int i = 1, u, v, w; i < n; ++i) {
    read(u), read(v), read(w);
    from[v] = w;
    addEdge(u, v, w);
  }
  dfs(1);
  for (int i = 1, u, v, w; i < n; ++i) {
    read(u), read(v), read(w);
    back[u] = w;
    node[i] = u;
  }
  Seg::build(1, 1, n);
  for (int i = 0, op, e, w, u, v; i < Q; ++i) {
    read(op);
    if (op == 1) {
      read(e), read(w);
      if (e >= n) {
        u = node[e - (n - 1)];
        Seg::update(1, 1, n, in[u], in[u], w - back[u]);
        back[u] = w;
      } else {
        u = ::e[e].to;
        Seg::update(1, 1, n, in[u], out[u], w - from[u]);
        from[u] = w;
      }
    } else {
      read(u), read(v);
      if (in[u] <= in[v] && out[v] <= out[u]) {
        printf("%lld\n", (Seg::get(v) - back[v]) - (Seg::get(u) - back[u]));
      } else {
        printf("%lld\n", Seg::query(1, 1, n, in[u], out[u]) +
                             (Seg::get(v) - back[v]) - (Seg::get(u) - back[u]));
      }
    }
  }
  return 0;
}