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 = 2e5 + 5, B = 18;
vector<pair<int, int>> G[N];
long long d[N];
int L[N], R[N], dfn, id[N], f[N][B], h[N], back[N];
void dfs(int x) {
  L[x] = R[x] = ++dfn;
  id[dfn] = x;
  for (auto e : G[x]) {
    d[e.first] = d[x] + e.second;
    h[e.first] = h[x] + 1;
    f[e.first][0] = x;
    dfs(e.first);
    R[x] = R[e.first];
  }
}
int lca(int u, int v) {
  if (h[u] > h[v]) swap(u, v);
  int del = h[v] - h[u];
  for (int i = 0; i < B; ++i)
    if (del >> i & 1) v = f[v][i];
  if (u == v) return u;
  for (int i = B - 1; i >= 0; --i) {
    if (f[u][i] != f[v][i]) {
      u = f[u][i];
      v = f[v][i];
    }
  }
  return f[u][0];
}
const long long INF = 1e18;
struct node {
  long long to1, lazy, deep;
  node() {
    to1 = INF;
    lazy = 0;
  }
  node(long long to1, long long lazy) : to1(to1), lazy(lazy) {}
  void work(long long del) {
    to1 += del;
    lazy += del;
  }
};
node operator+(const node &a, const node &b) {
  return node(min(a.to1, b.to1), 0LL);
}
node tree[N * 4];
void pd(int x) {
  tree[x + x].work(tree[x].lazy);
  tree[x + x + 1].work(tree[x].lazy);
  tree[x].lazy = 0;
}
node query(int x, int l, int r, int ql, int qr) {
  if (l > qr || r < ql) return node();
  if (l >= ql && r <= qr) return tree[x];
  pd(x);
  int mid = (l + r) / 2;
  return query(x + x, l, mid, ql, qr) + query(x + x + 1, mid + 1, r, ql, qr);
}
void add(int x, int l, int r, int ql, int qr, int c) {
  if (l > qr || r < ql) return;
  if (l >= ql && r <= qr) {
    tree[x].work(c);
    return;
  }
  pd(x);
  int mid = (l + r) / 2;
  add(x + x, l, mid, ql, qr, c);
  add(x + x + 1, mid + 1, r, ql, qr, c);
  tree[x] = tree[x + x] + tree[x + x + 1];
}
void build(int x, int l, int r) {
  if (l == r) {
    tree[x] = node(d[id[l]] + back[id[l]], 0);
    return;
  }
  int mid = (l + r) / 2;
  build(x + x, l, mid);
  build(x + x + 1, mid + 1, r);
  tree[x] = tree[x + x] + tree[x + x + 1];
}
int U[N * 2], V[N * 2], W[N * 2];
bool debug = 0;
int main() {
  int n, m;
  int seed = time(0);
  srand(seed);
  if (debug)
    n = 50, m = 50;
  else
    scanf("%d%d", &n, &m);
  for (int i = 1; i < n; ++i) {
    int &u = U[i], &v = V[i], &w = W[i];
    if (debug)
      u = rand() % i + 1, v = i + 1, w = rand() % (int)1e6 + 1;
    else
      scanf("%d%d%d", &u, &v, &w);
    G[u].push_back({v, w});
  }
  for (int i = 0; i < n - 1; ++i) {
    int &u = U[n + i], &v = V[n + i], &w = W[n + i];
    if (debug)
      u = i + 2, v = 1, w = rand() % (int)1e6 + 1;
    else
      scanf("%d%d%d", &u, &v, &w);
    back[u] = w;
  }
  dfs(1);
  for (int j = 1; j < B; ++j) {
    for (int i = 1; i <= n; ++i) f[i][j] = f[f[i][j - 1]][j - 1];
  }
  build(1, 1, n);
  while (m--) {
    int type;
    if (debug)
      type = rand() % 2 + 1;
    else
      scanf("%d", &type);
    if (type == 1) {
      int i, w;
      if (debug)
        i = rand() % (2 * n - 2) + 1, w = rand() % (int)1e6 + 5;
      else
        scanf("%d%d", &i, &w);
      if (i <= n - 1) {
        add(1, 1, n, L[V[i]], R[V[i]], w - W[i]);
        W[i] = w;
      } else {
        add(1, 1, n, L[U[i]], L[U[i]], w - back[U[i]]);
        back[U[i]] = w;
        W[i] = w;
      }
    } else {
      int u, v;
      if (debug)
        u = rand() % n + 1, v = rand() % n + 1;
      else
        scanf("%d%d", &u, &v);
      long long du = query(1, 1, n, L[u], L[u]).to1 - back[u];
      long long dv = query(1, 1, n, L[v], L[v]).to1 - back[v];
      long long ans;
      if (lca(u, v) == u) {
        ans = dv - du;
      } else {
        ans = query(1, 1, n, L[u], R[u]).to1 - du + dv;
      }
      printf("%I64d\n", ans);
      if (!debug) continue;
      static long long dis[N];
      static vector<pair<int, int>> g[N];
      for (int i = 1; i <= n; ++i) {
        dis[i] = INF;
        g[i].clear();
      }
      for (int i = 1; i <= 2 * n - 2; ++i) {
        g[U[i]].push_back({V[i], W[i]});
      }
      priority_queue<pair<long long, int>> q;
      dis[u] = 0;
      q.push({0, u});
      while (!q.empty()) {
        auto p = q.top();
        q.pop();
        if (dis[p.second] != -p.first) continue;
        for (auto e : g[p.second]) {
          if (dis[e.first] > dis[p.second] + e.second) {
            dis[e.first] = dis[p.second] + e.second;
            q.push({-dis[e.first], e.first});
          }
        }
      }
      assert(dis[v] == ans);
    }
  }
}