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;
int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = 10 * x + ch - '0';
    ch = getchar();
  }
  return x * f;
}
const int Size = 200001;
struct Edge {
  long long from, pos, v;
} w[Size << 1];
vector<Edge> to[Size];
long long n, q, cnt, anc[Size][21];
long long l[Size], r[Size], order[Size];
long long toroot[Size], dist[Size], deep[Size];
bool vis[Size];
struct Segment_Tree {
  struct node {
    int l, r;
    long long v, lazy;
  } tree[Size << 2];
  inline void Pushup(int rt) {
    tree[rt].v = min(tree[rt << 1].v, tree[rt << 1 | 1].v);
  }
  void Pushdown(int rt) {
    if (tree[rt].lazy) {
      tree[rt << 1].v += tree[rt].lazy;
      tree[rt << 1 | 1].v += tree[rt].lazy;
      tree[rt << 1].lazy += tree[rt].lazy;
      tree[rt << 1 | 1].lazy += tree[rt].lazy;
      tree[rt].lazy = 0;
    }
  }
  void Build1(int l = 1, int r = n, int rt = 1) {
    tree[rt].l = l;
    tree[rt].r = r;
    if (l == r) {
      tree[rt].v = toroot[order[l]] + dist[order[l]];
      return;
    }
    int mid = (tree[rt].l + tree[rt].r) >> 1;
    Build1(l, mid, rt << 1);
    Build1(mid + 1, r, rt << 1 | 1);
    Pushup(rt);
  }
  void Build2(int l = 1, int r = n, int rt = 1) {
    tree[rt].l = l;
    tree[rt].r = r;
    if (l == r) {
      tree[rt].v = dist[order[l]];
      return;
    }
    int mid = (tree[rt].l + tree[rt].r) >> 1;
    Build2(l, mid, rt << 1);
    Build2(mid + 1, r, rt << 1 | 1);
    Pushup(rt);
  }
  void Update(int l, int r, int v, int rt) {
    if (l <= tree[rt].l && tree[rt].r <= r) {
      tree[rt].v += v;
      tree[rt].lazy += v;
      return;
    }
    Pushdown(rt);
    int mid = (tree[rt].l + tree[rt].r) >> 1;
    if (l <= mid) Update(l, r, v, rt << 1);
    if (r > mid) Update(l, r, v, rt << 1 | 1);
    Pushup(rt);
  }
  long long Query(int l, int r, int rt) {
    if (l <= tree[rt].l && tree[rt].r <= r) {
      return tree[rt].v;
    }
    Pushdown(rt);
    long long mid = (tree[rt].l + tree[rt].r) >> 1, ans = 1000000000000;
    if (l <= mid) ans = min(ans, Query(l, r, rt << 1));
    if (r > mid) ans = min(ans, Query(l, r, rt << 1 | 1));
    return ans;
  }
} tree1, tree2;
void dfs(int x, long long p, long long dp) {
  deep[x] = dp;
  order[l[x] = ++cnt] = x;
  vis[x] = true;
  dist[x] = p;
  int len = to[x].size();
  for (int i = 0; i < len; i++) {
    int nxt = to[x][i].pos;
    if (!vis[nxt]) {
      anc[nxt][0] = x;
      dfs(nxt, p + to[x][i].v, dp + 1);
    }
  }
  r[x] = cnt;
}
void init() {
  n = read();
  q = read();
  for (int i = 1; i < n; i++) {
    w[i].from = read();
    w[i].pos = read();
    w[i].v = read();
    to[w[i].from].push_back(w[i]);
  }
  for (int i = 1; i < n; i++) {
    w[i + n - 1].from = read();
    w[i + n - 1].pos = read();
    w[i + n - 1].v = read();
    toroot[w[i + n - 1].from] = w[i + n - 1].v;
  }
  dfs(1, 0, 1);
  tree1.Build1();
  tree2.Build2();
}
int lca(int u, int v) {
  if (deep[u] < deep[v]) swap(u, v);
  for (int i = 20; i >= 0; i--) {
    if (deep[anc[u][i]] >= deep[v]) {
      u = anc[u][i];
    }
  }
  if (u == v) return u;
  for (int i = 20; i >= 0; i--) {
    if (anc[u][i] && anc[v][i] && anc[u][i] != anc[v][i]) {
      u = anc[u][i];
      v = anc[v][i];
    }
  }
  return anc[u][0];
}
int main() {
  init();
  while (q--) {
    int op = read();
    int u = read();
    int v = read();
    if (op == 1) {
      if (u < n) {
        long long now = w[u].v;
        tree1.Update(l[w[u].pos], r[w[u].pos], v - now, 1);
        tree2.Update(l[w[u].pos], r[w[u].pos], v - now, 1);
        w[u].v = v;
      } else {
        long long now = toroot[w[u].from];
        tree1.Update(l[w[u].from], l[w[u].from], v - now, 1);
        toroot[w[u].from] = v;
      }
    } else {
      if (l[u] <= l[v] && r[u] >= r[v]) {
        long long du = tree2.Query(l[u], l[u], 1);
        long long dv = tree2.Query(l[v], l[v], 1);
        long long ans = 0;
        printf("%I64d\n", max(du - dv, dv - du));
      } else {
        long long ans = tree1.Query(l[u], r[u], 1) +
                        tree2.Query(l[v], l[v], 1) - tree2.Query(l[u], l[u], 1);
        printf("%I64d\n", ans);
      }
    }
  }
  return 0;
}