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 maxn = 200004;
vector<int> g[maxn];
int n, q;
int _u[2 * maxn], _v[2 * maxn];
long long val[maxn];
int in[maxn], out[maxn], cnt;
int p[maxn][20];
int h[maxn];
long long val2[maxn];
int tv[maxn], U[maxn], V[maxn];
void enter() {
  cin >> n >> q;
  for (int i = (1), _b = (n); i < _b; ++i) {
    int u, v;
    long long c;
    cin >> u >> v >> c;
    g[u].push_back(v);
    val[v] = c;
    _u[i] = u;
    _v[i] = v;
  }
  for (int i = (n), _b = (2 * n - 1); i < _b; ++i) {
    int u, v;
    long long c;
    cin >> u >> v >> c;
    val2[u] = c;
    _u[i] = u;
    _v[i] = v;
  }
  for (int i = (1), _b = (q + 1); i < _b; ++i) cin >> tv[i] >> U[i] >> V[i];
}
void dfs(int u, int _anc, int hh) {
  h[u] = hh;
  p[u][0] = _anc;
  for (int i = (1), _b = (18); i < _b; ++i) p[u][i] = p[p[u][i - 1]][i - 1];
  in[u] = ++cnt;
  for (auto i : g[u]) dfs(i, u, hh + 1);
  out[u] = cnt;
}
bool isparent(int u, int v) {
  for (int i = 17; i >= 0; --i) {
    if (h[p[u][i]] >= h[v]) u = p[u][i];
  }
  if (u == v)
    return true;
  else
    return false;
}
struct node {
  long long sum, t;
  node() {}
  node(long long aa, long long bb) {
    sum = aa;
    t = bb;
  }
};
node seg[maxn * 4];
void push(int l, int r, int st) {
  long long T = seg[st].t;
  seg[st].t = 0;
  if (l < r) {
    seg[st * 2].sum += (T);
    seg[st * 2].t += T;
    seg[st * 2 + 1].sum += (T);
    seg[st * 2 + 1].t += T;
  }
}
void update(int l, int r, int u, int v, int st, long long val) {
  if (u <= l && r <= v) {
    seg[st].sum += (val);
    seg[st].t += val;
  } else if (l > v || r < u)
    return;
  else {
    int mid = (l + r) >> 1;
    push(l, r, st);
    update(l, mid, u, v, st * 2, val);
    update(mid + 1, r, u, v, st * 2 + 1, val);
    seg[st].sum = min(seg[st * 2].sum, seg[st * 2 + 1].sum);
  }
}
const long long oo = 10000000000000;
long long getrange(int l, int r, int u, int v, int st) {
  if (u <= l && r <= v)
    return seg[st].sum;
  else if (l > v || r < u)
    return oo;
  else {
    int mid = (l + r) >> 1;
    push(l, r, st);
    return min(getrange(l, mid, u, v, st * 2),
               getrange(mid + 1, r, u, v, st * 2 + 1));
  }
}
long long _get(int l, int r, int st, int q) {
  if (l == r)
    return seg[st].sum;
  else {
    int mid = (l + r) >> 1;
    push(l, r, st);
    if (mid >= q)
      return _get(l, mid, st * 2, q);
    else
      return _get(mid + 1, r, st * 2 + 1, q);
  }
}
long long getpath(int u) { return _get(1, n, 1, in[u]) - val2[u]; }
void solve() {
  dfs(1, 0, 1);
  for (int i = (2), _b = (n + 1); i < _b; ++i) {
    update(1, n, in[i], out[i], 1, val[i]);
    update(1, n, in[i], in[i], 1, val2[i]);
  }
  for (int i = (1), _b = (q + 1); i < _b; ++i) {
    if (tv[i] == 1) {
      if (U[i] >= n) {
        update(1, n, in[_u[U[i]]], in[_u[U[i]]], 1, V[i] - val2[_u[U[i]]]);
        val2[_u[U[i]]] = V[i];
      } else {
        update(1, n, in[_v[U[i]]], out[_v[U[i]]], 1, V[i] - val[_v[U[i]]]);
        val[_v[U[i]]] = V[i];
      }
    } else {
      if (isparent(V[i], U[i])) {
        cout << getpath(V[i]) - getpath(U[i]) << "\n";
      } else {
        cout << getrange(1, n, in[U[i]], out[U[i]], 1) - getpath(U[i]) +
                    getpath(V[i])
             << "\n";
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie();
  cout.tie();
  enter();
  solve();
}