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 N = 200123;
const int INF = 1e9;
struct Node {
  long long push;
  long long sum;
  long long mn;
};
Node t[10 * N];
int tin[N];
int tout[N];
int timer = 0;
int eda[2 * N], edb[2 * N], edc[2 * N];
vector<int> tr[N];
long long costup[N];
inline void setVal(int v, int l, int r, long long val) {
  t[v].push += val;
  t[v].mn += val;
  t[v].sum += val * (r - l + 1);
}
inline void push(int v, int l, int r) {
  int m = (l + r) >> 1;
  setVal(v * 2, l, m, t[v].push);
  setVal(v * 2 + 1, m + 1, r, t[v].push);
  t[v].push = 0;
}
void modify(int v, int l, int r, int lb, int rb, int add) {
  if (lb > r || rb < l) return;
  if (lb <= l && rb >= r) {
    setVal(v, l, r, add);
    return;
  }
  push(v, l, r);
  int m = (l + r) >> 1;
  modify(v * 2, l, m, lb, rb, add);
  modify(v * 2 + 1, m + 1, r, lb, rb, add);
  t[v].sum = t[v * 2].sum + t[v * 2 + 1].sum;
  t[v].mn = min(t[v * 2].mn, t[v * 2 + 1].mn);
}
void updMin(int v, int l, int r, int pos, int add) {
  if (l == r) {
    t[v].mn += add;
    return;
  }
  push(v, l, r);
  int m = (l + r) >> 1;
  if (pos <= m)
    updMin(v * 2, l, m, pos, add);
  else
    updMin(v * 2 + 1, m + 1, r, pos, add);
  t[v].sum = t[v * 2].sum + t[v * 2 + 1].sum;
  t[v].mn = min(t[v * 2].mn, t[v * 2 + 1].mn);
}
long long getSum(int v, int l, int r, int pos) {
  if (l == r) return t[v].sum;
  push(v, l, r);
  int m = (l + r) >> 1;
  if (pos <= m)
    return getSum(v * 2, l, m, pos);
  else
    return getSum(v * 2 + 1, m + 1, r, pos);
}
int getMin(int v, int l, int r, int lb, int rb) {
  if (lb > r || rb < l) return INF;
  if (lb <= l && rb >= r) return t[v].mn;
  push(v, l, r);
  int m = (l + r) >> 1;
  return min(getMin(v * 2, l, m, lb, rb), getMin(v * 2 + 1, m + 1, r, lb, rb));
}
void dfs(int v) {
  tin[v] = ++timer;
  for (int to : tr[v]) dfs(to);
  tout[v] = ++timer;
}
bool isPar(int a, int b) { return tin[a] <= tin[b] && tout[a] >= tout[b]; }
inline long long getSum(int v) { return v ? getSum(1, 1, timer, tin[v]) : 0; }
bool good[3 * N];
int main() {
  int n, q;
  scanf("%d%d", &n, &q);
  for (int i = 1; i <= 2 * n - 2; ++i) {
    scanf("%d%d%d", &eda[i], &edb[i], &edc[i]);
    if (edb[i] != 1)
      tr[eda[i]].push_back(edb[i]);
    else
      costup[eda[i]] = edc[i];
  }
  dfs(1);
  for (int i = 1; i <= n; ++i) good[tin[i]] = true;
  for (int i = 1; i <= timer; ++i)
    if (!good[i]) updMin(1, 1, timer, i, INF);
  for (int i = 1; i < n; ++i)
    modify(1, 1, timer, tin[edb[i]], tout[edb[i]], edc[i]);
  for (int i = n; i <= 2 * n - 2; ++i) updMin(1, 1, timer, tin[eda[i]], edc[i]);
  for (int i = 0; i < q; ++i) {
    int tp;
    scanf("%d", &tp);
    if (tp == 1) {
      int qi, qw;
      scanf("%d%d", &qi, &qw);
      if (edb[qi] == 1) {
        updMin(1, 1, timer, tin[eda[qi]], qw - costup[eda[qi]]);
        costup[eda[qi]] = qw;
      } else {
        modify(1, 1, timer, tin[edb[qi]], tout[edb[qi]], qw - edc[qi]);
        edc[qi] = qw;
      }
    } else {
      int u, v;
      scanf("%d%d", &u, &v);
      long long ans = 0;
      if (isPar(u, v)) {
        ans = getSum(v) - getSum(u);
      } else {
        ans = getSum(v) + getMin(1, 1, timer, tin[u], tout[u]) - getSum(u);
      }
      printf("%lld\n", ans);
    }
  }
  return 0;
}