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, num[200011];
int low[200011], to[200011];
vector<pair<int, int> > adj[200011];
vector<pair<int, pair<int, int> > > edgelist;
class MinSegTree {
 private:
  long long st[4 * 200011], lazy[4 * 200011];
  void push(int w, int L, int R) {
    if (!lazy[w])
      return;
    else if (L != R) {
      lazy[w * 2] += lazy[w];
      lazy[w * 2 + 1] += lazy[w];
    }
    if (st[w] < 0) st[w] = 0;
    st[w] += lazy[w];
    lazy[w] = 0;
  }

 public:
  void init() { memset(st, -1, sizeof(st)); }
  void update(int w, int L, int R, int a, int b, long long v) {
    push(w, L, R);
    if (b < L || a > R)
      return;
    else if (a <= L && b >= R) {
      lazy[w] += v;
      push(w, L, R);
    } else {
      update(w * 2, L, (L + R) / 2, a, b, v);
      update(w * 2 + 1, (L + R) / 2 + 1, R, a, b, v);
      st[w] = min(st[w * 2], st[w * 2 + 1]);
    }
  }
  long long query(int w, int L, int R, int a, int b) {
    push(w, L, R);
    if (b < L || a > R || st[w] < 0)
      return ((1LL << 60) + 123);
    else if (a <= L && b >= R)
      return st[w];
    else {
      long long q1 = query(w * 2, L, (L + R) / 2, a, b);
      long long q2 = query(w * 2 + 1, (L + R) / 2 + 1, R, a, b);
      return min(q1, q2);
    }
  }
} minst;
struct BIT {
  long long ft[200011];
  void update(int x, long long v) {
    while (x <= N) {
      ft[x] += v;
      x += (x & -x);
    }
  }
  long long query(int x) { return x > 0 ? ft[x] + query(x - (x & -x)) : 0; }
} sum;
void dfs(int x, int p) {
  static int cnt = 0;
  num[x] = low[x] = (++cnt);
  for (int i = 0; i < (int)adj[x].size(); i++) {
    int w = adj[x][i].first;
    int n = adj[x][i].second;
    if (n != p) {
      dfs(n, x);
      sum.update(num[n], w);
      sum.update(low[n] + 1, -w);
    }
  }
  low[x] = cnt;
}
int main() {
  if (fopen("data.in", "r")) freopen("data.in", "r", stdin);
  scanf("%d", &N);
  scanf("%d", &Q);
  for (int i = 1; i < N; i++) {
    int a, b, w;
    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &w);
    adj[a].push_back(make_pair(w, b));
    edgelist.push_back(make_pair(w, make_pair(a, b)));
  }
  for (int i = 2; i <= N; i++) {
    int a, b, w;
    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &w);
    to[a] = w;
    edgelist.push_back(make_pair(w, make_pair(a, b)));
  }
  dfs(1, 1);
  for (int i = 1; i <= N; i++)
    minst.update(1, 1, N, num[i], num[i], to[i] + sum.query(num[i]));
  for (int i = 0; i < Q; i++) {
    int a, b, t;
    scanf("%d", &t);
    scanf("%d", &a);
    scanf("%d", &b);
    if (t == 1) {
      int prev = edgelist[a - 1].first;
      edgelist[a - 1].first = b;
      if (a > N - 1) {
        int c = edgelist[a - 1].second.first;
        minst.update(1, 1, N, num[c], num[c],
                     -minst.query(1, 1, N, num[c], num[c]));
        minst.update(1, 1, N, num[c], num[c], sum.query(num[c]) + b);
      } else {
        int c = edgelist[a - 1].second.second;
        sum.update(num[c], -prev + b);
        sum.update(low[c] + 1, prev - b);
        minst.update(1, 1, N, num[c], low[c], -prev + b);
      }
    } else {
      if (num[b] <= low[a] && num[b] >= num[a]) {
        printf("%I64d\n", sum.query(num[b]) - sum.query(num[a]));
      } else {
        long long toRoot =
            minst.query(1, 1, N, num[a], low[a]) - sum.query(num[a]);
        printf("%I64d\n", toRoot + sum.query(num[b]));
      }
    }
  }
  return 0;
}