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;
vector<pair<int, int> > adj[400005];
int a[400005], b[400005], w[400005];
int anc[400005][20], depth[400005];
int ml[400005], mr[400005];
int pos = 1;
void dfs(int node, int p) {
  anc[node][0] = p;
  ml[node] = pos++;
  for (int i = 1; i < 20; ++i) {
    anc[node][i] = anc[anc[node][i - 1]][i - 1];
  }
  for (pair<int, int> edge : adj[node]) {
    int ch = edge.second;
    if (p == ch) {
      continue;
    }
    depth[ch] = depth[node] + 1;
    dfs(ch, node);
  }
  mr[node] = pos - 1;
}
bool isAncestor(int a, int b) {
  if (depth[a] > depth[b]) {
    return false;
  }
  int d = depth[b] - depth[a];
  for (int i = 0; i < 20; ++i) {
    if (d & (1 << i)) {
      b = anc[b][i];
    }
  }
  return a == b;
}
int id[400005], idw[400005];
void push(long long *seg, long long *lazy, int pos, int l, int r) {
  if (lazy[pos] != 0) {
    seg[pos] += lazy[pos];
    if (l != r) {
      lazy[pos * 2] += lazy[pos];
      lazy[pos * 2 + 1] += lazy[pos];
    }
    lazy[pos] = 0;
  }
}
void update(long long *seg, long long *lazy, int pos, int l, int r, int ql,
            int qr, int val) {
  push(seg, lazy, pos, l, r);
  if (r < ql || qr < l) {
    return;
  }
  if (ql <= l && r <= qr) {
    lazy[pos] = val;
    push(seg, lazy, pos, l, r);
    return;
  }
  int mid = (l + r) / 2;
  update(seg, lazy, pos * 2, l, mid, ql, qr, val);
  update(seg, lazy, pos * 2 + 1, mid + 1, r, ql, qr, val);
  seg[pos] = min(seg[pos * 2], seg[pos * 2 + 1]);
}
long long query(long long *seg, long long *lazy, int pos, int l, int r, int ql,
                int qr) {
  push(seg, lazy, pos, l, r);
  if (r < ql || qr < l) {
    return 1e18;
  }
  if (ql <= l && r <= qr) {
    return seg[pos];
  }
  int mid = (l + r) / 2;
  return min(query(seg, lazy, pos * 2, l, mid, ql, qr),
             query(seg, lazy, pos * 2 + 1, mid + 1, r, ql, qr));
}
long long seg[400005 * 4], lazy[400005 * 4], qq[400005 * 4], ww[400005 * 4];
int g[400005];
void solve() {
  int n, q;
  scanf("%d %d ", &n, &q);
  for (int i = 1; i <= n - 1; ++i) {
    scanf("%d %d %d ", &a[i], &b[i], &w[i]);
    adj[a[i]].push_back(make_pair(i, b[i]));
  }
  for (int i = n; i <= 2 * n - 2; ++i) {
    int x, y, z;
    scanf("%d %d %d ", &x, &y, &z);
    id[i] = x;
    idw[i] = z;
    g[x] = i;
  }
  dfs(1, 0);
  for (int i = 1; i <= n - 1; ++i) {
    update(seg, lazy, 1, 1, n, ml[b[i]], mr[b[i]], w[i]);
    update(qq, ww, 1, 1, n, ml[b[i]], mr[b[i]], w[i]);
  }
  for (int i = n; i <= 2 * n - 2; ++i) {
    update(qq, ww, 1, 1, n, ml[id[i]], ml[id[i]], idw[i]);
  }
  while (q--) {
    int type, x, y;
    scanf("%d %d %d ", &type, &x, &y);
    if (type == 1) {
      if (x <= n - 1) {
        int ch = b[x];
        update(seg, lazy, 1, 1, n, ml[ch], mr[ch], y - w[x]);
        update(qq, ww, 1, 1, n, ml[ch], mr[ch], y - w[x]);
        w[x] = y;
      } else {
        int ch = id[x];
        update(qq, ww, 1, 1, n, ml[ch], ml[ch], y - idw[x]);
        idw[x] = y;
      }
    } else {
      long long ret = 0;
      if (isAncestor(x, y)) {
        ret = query(seg, lazy, 1, 1, n, ml[y], ml[y]) -
              query(seg, lazy, 1, 1, n, ml[x], ml[x]);
      } else {
        ret = query(qq, ww, 1, 1, n, ml[x], mr[x]) -
              query(seg, lazy, 1, 1, n, ml[x], ml[x]);
        ret += query(seg, lazy, 1, 1, n, ml[y], ml[y]);
      }
      printf("%lld\n", ret);
    }
  }
}
int main() {
  solve();
  return 0;
}