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 n, q;
set<pair<int, long long> > adj[222222];
long long dist_to_root[222222];
long long dist[222222];
int anc[222222][22];
int dep[222222];
void dfs(int cur, int par = 1) {
  dep[cur] = dep[par] + 1;
  anc[cur][0] = par;
  for (int i = 1; i <= 20; i++) anc[cur][i] = anc[anc[cur][i - 1]][i - 1];
  for (pair<int, long long> p : adj[cur]) {
    int v = p.first;
    if (v == par) continue;
    dist[v] = dist[cur] + p.second;
    dfs(v, cur);
  }
}
int lca(int u, int v) {
  if (dep[u] < dep[v]) swap(u, v);
  for (int i = 20; i >= 0; i--)
    if (dep[anc[u][i]] >= dep[v]) u = anc[u][i];
  if (u == v) return u;
  for (int i = 20; i >= 0; i--)
    if (anc[u][i] != anc[v][i]) u = anc[u][i], v = anc[v][i];
  return anc[u][0];
}
long long flat[222222];
long long flatdist[222222];
int cnt;
int st[222222], en[222222];
void flatten(int cur) {
  ++cnt;
  st[cur] = cnt;
  flat[cnt] = dist[cur] + dist_to_root[cur];
  flatdist[cnt] = dist[cur];
  for (pair<int, long long> p : adj[cur]) flatten(p.first);
  en[cur] = cnt;
}
long long t[888888];
long long lazy[888888];
void build(int x, int l, int r) {
  if (l > r) return;
  if (l == r)
    t[x] = flat[l];
  else {
    int mid = (l + r) / 2;
    build(2 * x, l, mid);
    build(2 * x + 1, mid + 1, r);
    t[x] = min(t[2 * x], t[2 * x + 1]);
  }
}
void prop(int x, int l, int r) {
  t[x] += lazy[x];
  if (l != r) {
    lazy[2 * x] += lazy[x];
    lazy[2 * x + 1] += lazy[x];
  }
  lazy[x] = 0;
}
void update(int x, int l, int r, int a, int b, long long v) {
  prop(x, l, r);
  if (l > r || r < a || b < l) return;
  if (a <= l && r <= b) {
    lazy[x] += v;
    prop(x, l, r);
    return;
  }
  int mid = (l + r) / 2;
  update(2 * x, l, mid, a, b, v);
  update(2 * x + 1, mid + 1, r, a, b, v);
  t[x] = min(t[2 * x], t[2 * x + 1]);
}
long long query(int x, int l, int r, int a, int b) {
  prop(x, l, r);
  if (l > r || r < a || b < l) return 1e16;
  if (a <= l && r <= b) {
    return t[x];
  }
  prop(x, l, r);
  int mid = (l + r) / 2;
  long long res = query(2 * x, l, mid, a, b);
  res = min(res, query(2 * x + 1, mid + 1, r, a, b));
  return res;
}
void update(int a, int b, long long v) { update(1, 1, n, a, b, v); }
long long query(int a, int b) { return query(1, 1, n, a, b); }
long long t2[888888];
long long lazy2[888888];
void build2(int x, int l, int r) {
  if (l > r) return;
  if (l == r)
    t2[x] = flatdist[l];
  else {
    int mid = (l + r) / 2;
    build2(2 * x, l, mid);
    build2(2 * x + 1, mid + 1, r);
    t2[x] = t2[2 * x] + t2[2 * x + 1];
  }
}
void prop2(int x, int l, int r) {
  t2[x] += lazy2[x] * (r - l + 1);
  if (l != r) {
    lazy2[2 * x] += lazy2[x];
    lazy2[2 * x + 1] += lazy2[x];
  }
  lazy2[x] = 0;
}
void update2(int x, int l, int r, int a, int b, long long v) {
  prop2(x, l, r);
  if (l > r || r < a || b < l) return;
  if (a <= l && r <= b) {
    lazy2[x] += v;
    prop2(x, l, r);
    return;
  }
  int mid = (l + r) / 2;
  update2(2 * x, l, mid, a, b, v);
  update2(2 * x + 1, mid + 1, r, a, b, v);
  t2[x] = t2[2 * x] + t2[2 * x + 1];
}
long long query2(int x, int l, int r, int a, int b) {
  prop2(x, l, r);
  if (l > r || r < a || b < l) return 0;
  if (a <= l && r <= b) {
    return t2[x];
  }
  prop2(x, l, r);
  int mid = (l + r) / 2;
  long long res = query2(2 * x, l, mid, a, b);
  res += query2(2 * x + 1, mid + 1, r, a, b);
  return res;
}
void update2(int a, int b, long long v) { update2(1, 1, n, a, b, v); }
long long query2(int a, int b) { return query2(1, 1, n, a, b); }
long long ea[444444], eb[444444], ec[444444];
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> q;
  for (int i = 1; i <= n - 1; i++) {
    long long a, b, c;
    cin >> a >> b >> c;
    ea[i] = a, eb[i] = b, ec[i] = c;
    adj[a].insert({b, c});
  }
  for (int i = n; i <= 2 * n - 2; i++) {
    long long a, b, c;
    cin >> a >> b >> c;
    ea[i] = a, eb[i] = b, ec[i] = c;
    dist_to_root[a] = c;
  }
  dfs(1);
  flatten(1);
  memset(t, 63, sizeof t);
  build(1, 1, n);
  build2(1, 1, n);
  while (q--) {
    int type;
    cin >> type;
    if (type == 1) {
      int i, w;
      cin >> i >> w;
      int v = eb[i];
      if (i <= n - 1) {
        update(st[v], en[v], w - ec[i]);
        update2(st[v], en[v], w - ec[i]);
      } else {
        update(st[ea[i]], st[ea[i]], w - ec[i]);
      }
      ec[i] = w;
    } else {
      int u, v;
      cin >> u >> v;
      int l = lca(u, v);
      if (l == u)
        cout << query2(st[v], st[v]) - query2(st[u], st[u]) << endl;
      else
        cout << query(st[u], en[u]) - query2(st[u], st[u]) +
                    query2(st[v], st[v])
             << endl;
    }
  }
  return 0;
}