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 = 200000 + 10;
const long long INF = 1e18;
int n, q;
struct Edge {
  int u, v;
  long long w;
  Edge(int _u = 0, int _v = 0, long long _w = 0) : u(_u), v(_v), w(_w) {}
};
vector<Edge> E;
int E_size;
vector<int> G[N];
int ptr[2 * N];
void adjListInit(int l, int r) {
  E.clear();
  E_size = 0;
  for (int i = l; i <= r; i++) G[i].clear();
}
void addEdge(int u, int v, long long w, int i) {
  E.push_back(Edge(u, v, w));
  E_size++;
  ptr[i] = E_size - 1;
  G[u].push_back(E_size - 1);
}
vector<Edge> Eback;
int Gback[N];
int Eback_size;
long long dist[N];
int in[N], out[N];
int peg[N];
int dfs_clock;
inline void dfsInit() {
  dist[1] = 0;
  dfs_clock = 0;
}
void dfs(int u, int pre) {
  in[u] = ++dfs_clock;
  peg[in[u]] = u;
  for (int i = 0; i < G[u].size(); i++) {
    Edge e = E[G[u][i]];
    int v = e.v;
    if (v == pre) continue;
    dist[v] = dist[u] + e.w;
    dfs(v, u);
  }
  out[u] = dfs_clock;
}
struct Node {
  int l, r;
  long long val, lazy;
  void update(long long x) { val += x, lazy += x; }
} node[N << 2];
inline void pushdown(int rt) {
  if (node[rt].lazy) {
    node[rt << 1].update(node[rt].lazy);
    node[rt << 1 | 1].update(node[rt].lazy);
    node[rt].lazy = 0;
  }
}
inline void pushup(int rt) {
  node[rt].val = min(node[rt << 1].val, node[rt << 1 | 1].val);
}
void build(int root, int l, int r) {
  node[root].l = l;
  node[root].r = r;
  node[root].val = 0;
  node[root].lazy = 0;
  if (l == r) {
    int p = peg[l];
    node[root].val = dist[p] + Eback[Gback[p]].w;
  } else {
    int mid = l + (r - l) / 2;
    build(root * 2, l, mid);
    build(root * 2 + 1, mid + 1, r);
    pushup(root);
  }
}
void update(int root, int st, int ed, int val) {
  if (st > node[root].r || ed < node[root].l) return;
  if (st <= node[root].l && node[root].r <= ed)
    node[root].update(val);
  else {
    pushdown(root);
    update(root * 2, st, ed, val);
    update(root * 2 + 1, st, ed, val);
    pushup(root);
  }
}
long long query(int root, int st, int ed) {
  if (ed < node[root].l || node[root].r < st) return INF;
  if (st <= node[root].l && node[root].r <= ed)
    return node[root].val;
  else {
    pushdown(root);
    long long lson = query(root * 2, st, ed);
    long long rson = query(root * 2 + 1, st, ed);
    pushup(root);
    return min(lson, rson);
  }
}
int main() {
  cin >> n >> q;
  adjListInit(1, n);
  for (int i = 1; i <= n - 1; i++) {
    int a, b;
    long long c;
    scanf("%d%d%I64d", &a, &b, &c);
    addEdge(a, b, c, i);
  }
  dfsInit();
  dfs(1, -1);
  Eback.clear();
  Eback_size = 0;
  for (int i = n, a, b, c; i <= 2 * n - 2; i++) {
    scanf("%d%d%d", &a, &b, &c);
    Eback.push_back(Edge(a, b, c));
    Eback_size++;
    ptr[i] = Eback_size - 1;
    Gback[a] = Eback_size - 1;
  }
  Eback.push_back(Edge(1, 1, 0));
  Eback_size++;
  Gback[1] = Eback_size - 1;
  build(1, 1, n);
  for (int i = 1, type; i <= q; i++) {
    scanf("%d", &type);
    if (type == 1) {
      int id;
      long long w;
      scanf("%d%I64d", &id, &w);
      if (id < n) {
        Edge &e = E[ptr[id]];
        update(1, in[e.v], out[e.v], w - e.w);
        e.w = w;
      } else {
        Edge &e = Eback[ptr[id]];
        update(1, in[e.u], in[e.u], w - e.w);
        e.w = w;
      }
    }
    if (type == 2) {
      int u, v;
      scanf("%d%d", &u, &v);
      if (in[u] <= in[v] && in[v] <= out[u]) {
        long long du = query(1, in[u], in[u]) - Eback[Gback[u]].w;
        long long dv = query(1, in[v], in[v]) - Eback[Gback[v]].w;
        printf("%I64d\n", dv - du);
      } else {
        long long ans = query(1, in[u], out[u]);
        long long du = query(1, in[u], in[u]) - Eback[Gback[u]].w;
        long long dv = query(1, in[v], in[v]) - Eback[Gback[v]].w;
        ans -= du;
        ans += dv;
        printf("%I64d\n", ans);
      }
    }
  }
}