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 = 2e5 + 10;
int dfn[maxn], seq[maxn], leave[maxn], vl[maxn];
long long dep[maxn];
vector<pair<int, int> > edl[maxn];
int top = 0, n, q;
struct Segment {
  long long mark, minvl;
} seg[maxn * 4];
struct Edge {
  int u, v, w;
} ed[maxn * 2];
void dfs(int x) {
  seq[++top] = x;
  dfn[x] = top;
  for (int i = 0; i < edl[x].size(); i++) {
    dep[edl[x][i].first] = dep[x] + edl[x][i].second;
    dfs(edl[x][i].first);
  }
  leave[x] = top;
}
inline void update(int x) {
  seg[x].minvl = min(seg[x << 1].minvl, seg[(x << 1) | 1].minvl) + seg[x].mark;
}
inline void pushdown(int x) {
  seg[x << 1].mark += seg[x].mark;
  seg[x << 1].minvl += seg[x].mark;
  seg[(x << 1) | 1].mark += seg[x].mark;
  seg[(x << 1) | 1].minvl += seg[x].mark;
  seg[x].mark = 0;
}
void build(int x, int l, int r) {
  seg[x].mark = 0;
  if (l == r) {
    seg[x].minvl = dep[seq[l]] + vl[seq[l]];
    return;
  }
  int mid = (l + r) >> 1;
  build(x << 1, l, mid);
  build((x << 1) | 1, mid + 1, r);
  update(x);
}
void editdelta(int x, int l, int r, int nowl, int nowr, int d) {
  if (nowl <= l && r <= nowr) {
    seg[x].mark += d;
    seg[x].minvl += d;
    return;
  }
  int mid = (l + r) >> 1;
  pushdown(x);
  if (nowl <= mid) editdelta(x << 1, l, mid, nowl, nowr, d);
  if (nowr > mid) editdelta((x << 1) | 1, mid + 1, r, nowl, nowr, d);
  update(x);
}
void editpoint(int u, int d) {
  int x = 1, l = 1, r = n;
  while (l < r) {
    int mid = (l + r) >> 1;
    if (u <= mid) {
      x <<= 1;
      r = mid;
    } else {
      x = (x << 1) | 1;
      l = mid + 1;
    }
  }
  seg[x].minvl += d;
  while (x > 1) {
    x >>= 1;
    update(x);
  }
}
long long askdep(int u) {
  long long ret = dep[u];
  u = dfn[u];
  int x = 1, l = 1, r = n;
  while (l < r) {
    ret += seg[x].mark;
    int mid = (l + r) >> 1;
    if (u <= mid) {
      x <<= 1;
      r = mid;
    } else {
      x = (x << 1) | 1;
      l = mid + 1;
    }
  }
  return ret + seg[x].mark;
}
void editedge(int id, int w) {
  if (id <= n - 1) {
    editdelta(1, 1, n, dfn[ed[id].v], leave[ed[id].v], w - ed[id].w);
  } else {
    editpoint(dfn[ed[id].u], w - vl[ed[id].u]);
    vl[ed[id].u] = w;
  }
  ed[id].w = w;
}
long long askmin(int x, int l, int r, int nowl, int nowr) {
  if (nowl <= l && r <= nowr) return seg[x].minvl;
  int mid = (l + r) >> 1;
  pushdown(x);
  if (nowr <= mid) return askmin(x + x, l, mid, nowl, nowr);
  if (nowl > mid) return askmin(x + x + 1, mid + 1, r, nowl, nowr);
  return min(askmin(x + x, l, mid, nowl, nowr),
             askmin(x + x + 1, mid + 1, r, nowl, nowr));
}
long long askans(int s, int t) {
  if (dfn[s] <= dfn[t] && leave[t] <= leave[s]) return askdep(t) - askdep(s);
  return askmin(1, 1, n, dfn[s], leave[s]) - askdep(s) + askdep(t);
}
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return f < 0 ? -x : x;
}
int main() {
  n = read();
  q = read();
  for (int i = 1; i <= n - 1; i++) {
    ed[i].u = read();
    ed[i].v = read();
    ed[i].w = read();
    edl[ed[i].u].push_back(make_pair(ed[i].v, ed[i].w));
  }
  for (int i = n; i <= 2 * n - 2; i++) {
    ed[i].u = read();
    ed[i].v = read();
    ed[i].w = read();
    vl[ed[i].u] = ed[i].w;
  }
  dep[1] = 0;
  dfs(1);
  build(1, 1, n);
  for (int i = 1; i <= q; i++) {
    int op = read();
    if (op == 1) {
      int id, w;
      id = read();
      w = read();
      editedge(id, w);
    } else {
      int s, t;
      s = read();
      t = read();
      cout << askans(s, t) << '\n';
    }
  }
  return 0;
}