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;
long long readi() {
  long long input = 0;
  char c = ' ';
  while (c < '-') {
    c = getchar();
  }
  bool negative = false;
  if (c == '-') {
    negative = true;
    c = getchar();
  }
  while (c >= '0') {
    input = 10 * input + (c - '0');
    c = getchar();
  }
  if (negative) {
    input = -input;
  }
  return input;
}
string reads() {
  string input = "";
  char c = ' ';
  while (c <= ' ') {
    c = getchar();
  }
  while (c > ' ') {
    input += c;
    c = getchar();
  }
  return input;
}
void printi(long long output) {
  if (output == 0) {
    putchar('0');
    return;
  }
  if (output < 0) {
    putchar('-');
    output = -output;
  }
  vector<char> vout;
  while (output) {
    vout.push_back((output % 10) + '0');
    output /= 10;
  }
  for (int i = vout.size() - 1; i >= 0; i--) {
    putchar(vout[i]);
  }
  return;
}
void prints(string output) {
  for (int i = 0; i < output.length(); i++) {
    putchar(output[i]);
  }
  return;
}
int N, Q, T;
pair<int, int> eid[400010];
long long siz[400010];
long long len[400010];
long long dist[400010];
vector<pair<long long, long long> > edge[400010];
int parent[400010];
int t[400010], deepest[400010];
long long tree[400010];
long long minst[4 * 400010];
long long lazy[4 * 400010];
void dfs_t(int u) {
  t[u] = T;
  deepest[u] = T;
  T++;
  for (int i = 0; i < edge[u].size(); i++) {
    int v = edge[u][i].second;
    if (v == parent[u]) {
      continue;
    }
    dfs_t(v);
    deepest[u] = max(deepest[u], deepest[v]);
  }
  return;
}
void dfs_dist(int u) {
  for (int i = 0; i < edge[u].size(); i++) {
    int v = edge[u][i].second;
    long long d = edge[u][i].first;
    if (v == parent[u]) {
      continue;
    }
    dist[v] = dist[u] + d;
    dfs_dist(v);
  }
  return;
}
void upd(int lt, int rt, long long val) {
  for (int e = lt + 1; e <= N; e += e & (-e)) {
    tree[e] += val;
  }
  for (int e = rt + 2; e <= N; e += e & (-e)) {
    tree[e] -= val;
  }
  return;
}
long long qu(int idx) {
  long long sum = 0;
  for (int e = idx + 1; e > 0; e -= e & (-e)) {
    sum += tree[e];
  }
  return sum;
}
void down(int w, int L, int R) {
  minst[w] += lazy[w];
  if (L != R) {
    lazy[2 * w] += lazy[w];
    lazy[2 * w + 1] += lazy[w];
  }
  lazy[w] = 0;
  return;
}
void rangeupdate(int w, int L, int R, int a, int b, long long val) {
  down(w, L, R);
  if (b < L || R < a) {
    return;
  }
  if (R <= b && a <= L) {
    minst[w] += val;
    if (L != R) {
      lazy[2 * w] += val;
      lazy[2 * w + 1] += val;
    }
    return;
  }
  int mid = (L + R) / 2;
  rangeupdate(2 * w, L, mid, a, b, val);
  rangeupdate(2 * w + 1, mid + 1, R, a, b, val);
  minst[w] =
      min(minst[2 * w] + lazy[2 * w], minst[2 * w + 1] + lazy[2 * w + 1]);
  return;
}
long long minquery(int w, int L, int R, int a, int b) {
  down(w, L, R);
  if (b < L || R < a) {
    return 1000000000000000861ll;
  }
  if (a <= L && R <= b) {
    return minst[w];
  }
  int mid = (L + R) / 2;
  return min(minquery(2 * w, L, mid, a, b),
             minquery(2 * w + 1, mid + 1, R, a, b));
}
int32_t main() {
  if (fopen("cf838b.in", "r")) {
    freopen("cf838b.in", "r", stdin);
  }
  N = readi();
  Q = readi();
  for (int i = 1; i < N; i++) {
    long long a, b, c;
    a = readi();
    b = readi();
    c = readi();
    a--;
    b--;
    edge[a].push_back(make_pair(c, b));
    edge[b].push_back(make_pair(c, a));
    parent[b] = a;
    eid[i] = make_pair(a, b);
    siz[i] = c;
  }
  for (int i = 1; i < N; i++) {
    long long a, b, c;
    a = readi();
    b = readi();
    c = readi();
    a--;
    b--;
    len[a] = c;
    siz[i + N - 1] = c;
    eid[i + N - 1] = make_pair(a, b);
  }
  parent[0] = N;
  dfs_t(0);
  dfs_dist(0);
  for (int i = 0; i < N; i++) {
    upd(t[i], t[i], dist[i]);
  }
  for (int i = 0; i < N; i++) {
    rangeupdate(1, 0, N - 1, t[i], t[i], dist[i] + len[i]);
  }
  while (Q--) {
    int qid;
    qid = readi();
    if (qid == 1) {
      int a;
      long long b;
      a = readi();
      b = readi();
      int u = eid[a].first, v = eid[a].second;
      long long was = siz[a];
      long long gain = b - was;
      if (v) {
        int t0 = t[v], t1 = deepest[v];
        upd(t0, t1, gain);
        rangeupdate(1, 0, N - 1, t0, t1, gain);
      } else {
        int t0 = t[u];
        rangeupdate(1, 0, N - 1, t0, t0, gain);
      }
      siz[a] = b;
    } else {
      long long ans = 1000000000000000861ll;
      int u, v;
      u = readi();
      v = readi();
      u--;
      v--;
      if (t[u] <= t[v] && t[v] <= deepest[u]) {
        ans = min(ans, qu(t[v]) - qu(t[u]));
      }
      ans = min(ans,
                minquery(1, 0, N - 1, t[u], deepest[u]) - qu(t[u]) + qu(t[v]));
      printi(ans);
      putchar('\n');
    }
  }
}