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>
#pragma warning(disable : 4996)
const long long INF = (1ll << 63) - 1ll;
const long double INFd = 28e14;
const long long inf = (1 << 31) - 1;
const long double EPS = 1e-8;
const long double PI = acos(-1.0);
const long long mod = 7 + 1e9;
using namespace std;
void OUT(bool f) {
  if (f)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
void Out(bool f) {
  if (f)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
void out(bool f) {
  if (f)
    cout << "yes" << endl;
  else
    cout << "no" << endl;
}
inline int next_rand() { return abs(rand() * rand() + rand()); }
struct __debug__ {
  __debug__(string filename, bool f = false) {
    if (filename == "") return;
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string filein = filename + ".in";
    string fileout = filename + ".out";
    freopen(filein.c_str(), "r", stdin);
    freopen(fileout.c_str(), "w", stdout);
  }
  ~__debug__() {}
};
__debug__ DEBUG("");
void gen();
void solve();
int main() {
  srand('M' + 'A' + 'S' + 'L' + '0' + 'F');
  srand(time(0));
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
}
int n, q;
const int maxn = 200005;
struct Egde {
  int f;
  int t;
  long long w;
};
vector<Egde> E;
Egde ed;
vector<int> e[maxn];
long long gotoparent[maxn];
int firstinp[maxn];
int lastinp[maxn];
vector<int> euler;
void dfs(int v = 0) {
  firstinp[v] = euler.size();
  euler.push_back(v);
  for (auto i : e[v]) {
    dfs(E[i].t - 1);
  }
  lastinp[v] = euler.size();
  euler.push_back(v);
}
struct SGTree {
  static const int maxn = 1 << 20;
  long long s[maxn * 2];
  long long p[maxn * 2];
  void push(int v, int l, int r) {
    s[v] += p[v];
    if (l + 1 == r) {
      p[v] = 0;
      return;
    }
    p[v * 2 + 1] += p[v];
    p[v * 2 + 2] += p[v];
    p[v] = 0;
  }
  void add(int L, int R, long long d, int v = 0, int l = 0, int r = maxn) {
    push(v, l, r);
    if (L >= r || R < l) return;
    if (L <= l && r - 1 <= R) {
      p[v] += d;
      push(v, l, r);
      return;
    }
    add(L, R, d, v * 2 + 1, l, l + r >> 1);
    add(L, R, d, v * 2 + 2, l + r >> 1, r);
    s[v] = min(s[v * 2 + 1], s[v * 2 + 2]);
  }
  long long ask(int pos, int v = 0, int l = 0, int r = maxn) {
    push(v, l, r);
    if (l + 1 == r) return s[v];
    if ((l + r >> 1) > pos)
      return ask(pos, v * 2 + 1, l, l + r >> 1);
    else
      return ask(pos, v * 2 + 2, l + r >> 1, r);
  }
  long long minsg(int L, int R, int v = 0, int l = 0, int r = maxn) {
    push(v, l, r);
    if (L >= r || R < l) return INF;
    if (L <= l && r - 1 <= R) {
      return s[v];
    }
    return min(minsg(L, R, v * 2 + 1, l, l + r >> 1),
               minsg(L, R, v * 2 + 2, l + r >> 1, r));
  }
} t;
void solve() {
  cin >> n >> q;
  for (int i = 0; i < 2 * n - 2; ++i) {
    cin >> ed.f >> ed.t >> ed.w;
    E.push_back(ed);
    if (ed.t == 1) {
      gotoparent[ed.f - 1] = ed.w;
    } else {
      e[ed.f - 1].push_back(i);
    }
  }
  dfs();
  for (int i = 0; i < n; ++i)
    t.add(firstinp[i], firstinp[i], gotoparent[i]),
        t.add(lastinp[i], lastinp[i], gotoparent[i]);
  for (auto i : E) {
    if (i.t != 1) {
      t.add(firstinp[i.t - 1], lastinp[i.t - 1], i.w);
    }
  }
  while (q--) {
    int y;
    cin >> y;
    if (y == 1) {
      int a, b;
      cin >> a >> b;
      --a;
      if (E[a].t == 1) {
        t.add(firstinp[E[a].f - 1], firstinp[E[a].f - 1],
              b - gotoparent[E[a].f - 1]);
        t.add(lastinp[E[a].f - 1], lastinp[E[a].f - 1],
              b - gotoparent[E[a].f - 1]);
        gotoparent[E[a].f - 1] = b;
      } else {
        t.add(firstinp[E[a].t - 1], lastinp[E[a].t - 1], (b - E[a].w));
        E[a].w = b;
      }
    } else {
      int a, b;
      cin >> a >> b;
      if (a == b) {
        cout << 0 << endl;
        continue;
      }
      bool f = false;
      if (firstinp[a - 1] < firstinp[b - 1] && lastinp[b - 1] < lastinp[a - 1])
        f = true;
      cout << (!f ? t.minsg(firstinp[a - 1], lastinp[a - 1]) -
                        t.ask(firstinp[a - 1]) + gotoparent[a - 1] +
                        t.ask(firstinp[b - 1]) - gotoparent[b - 1]
                  : t.ask(firstinp[b - 1]) - gotoparent[b - 1] +
                        gotoparent[a - 1] - t.ask(firstinp[a - 1]))
           << endl;
    }
  }
}