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;
vector<vector<int> > adj(200001);
int n, start[200001], finish[200001], timer = 0, u[2 * 200001], v[2 * 200001],
                                      w[2 * 200001];
long long T[200001];
typedef struct node {
  int leftEnd;
  int rightEnd;
  long long lazy;
  long long ans;
  node *leftChild;
  node *rightChild;
} node;
node *CreateNode(int leftEnd, int rightEnd) {
  node *temp = new node;
  temp->leftEnd = leftEnd;
  temp->rightEnd = rightEnd;
  temp->lazy = 0;
  temp->ans = 0;
  temp->leftChild = NULL;
  temp->rightChild = NULL;
  return temp;
}
node *BuildSegmentTree(int i, int j) {
  node *temp = CreateNode(i, j);
  if (i != j) {
    int k = (i + j) / 2;
    temp->leftChild = BuildSegmentTree(i, k);
    temp->rightChild = BuildSegmentTree(k + 1, j);
  }
  return temp;
}
void TraverseSegmentTree(node *root) {
  if (root) {
    TraverseSegmentTree(root->leftChild);
    TraverseSegmentTree(root->rightChild);
    printf("%d %d\n", root->leftEnd, root->rightEnd);
  }
}
void UpdateNode(node *currentNode, long long x) {
  currentNode->lazy += x;
  currentNode->ans += x;
}
void LazyUpdateChildren(node *currentNode) {
  UpdateNode(currentNode->leftChild, currentNode->lazy);
  UpdateNode(currentNode->rightChild, currentNode->lazy);
  currentNode->lazy = 0;
}
void Merge(node *currentNode) {
  currentNode->ans =
      min(currentNode->leftChild->ans, currentNode->rightChild->ans);
}
void Update(node *currentNode, int l, int r, int x) {
  if (r < currentNode->leftEnd || currentNode->rightEnd < l)
    return;
  else {
    l = max(l, currentNode->leftEnd);
    r = min(r, currentNode->rightEnd);
    if (l == currentNode->leftEnd && r == currentNode->rightEnd)
      UpdateNode(currentNode, x);
    else {
      LazyUpdateChildren(currentNode);
      Update(currentNode->leftChild, l, r, x);
      Update(currentNode->rightChild, l, r, x);
      Merge(currentNode);
    }
  }
}
long long Query(node *currentNode, int l, int r) {
  if (r < currentNode->leftEnd || currentNode->rightEnd < l)
    return LLONG_MAX;
  else {
    long long ans;
    l = max(l, currentNode->leftEnd);
    r = min(r, currentNode->rightEnd);
    if (l == currentNode->leftEnd && r == currentNode->rightEnd)
      ans = currentNode->ans;
    else {
      LazyUpdateChildren(currentNode);
      ans = min(Query(currentNode->leftChild, l, r),
                Query(currentNode->rightChild, l, r));
      Merge(currentNode);
    }
    return ans;
  }
}
node *root;
void DFS(int i) {
  start[i] = ++timer;
  for (auto k : adj[i]) DFS(k);
  finish[i] = timer;
}
void Update(int i, int x) {
  for (; i <= n; i += (i & -i)) T[i] += x;
}
long long Query(int i) {
  long long ans = 0;
  for (; i > 0; i -= (i & -i)) ans += T[i];
  return ans;
}
void PreProcess(int n) {
  for (int x = 1; x <= 2 * n - 2; ++x) {
    if (v[x] == 1) {
      int k = u[x];
      Update(root, start[k], start[k], w[x]);
    } else {
      int k = v[x];
      Update(root, start[k], finish[k], w[x]);
      Update(start[k], w[x]);
      Update(finish[k] + 1, -w[x]);
    }
  }
}
void UpdateEdge(int i, int x) {
  if (v[i] == 1) {
    int k = u[i];
    Update(root, start[k], start[k], x - w[i]);
    w[i] = x;
  } else {
    int k = v[i];
    x -= w[i];
    w[i] += x;
    Update(root, start[k], finish[k], x);
    Update(start[k], x);
    Update(finish[k] + 1, -x);
  }
}
bool IsAncestor(int u, int v) {
  return (start[u] <= start[v] && finish[v] <= finish[u]);
}
long long Query(int u, int v) {
  long long ans = 0;
  if (!IsAncestor(u, v)) ans = Query(root, start[u], finish[u]);
  ans += (Query(start[v]) - Query(start[u]));
  return ans;
}
int main() {
  int q;
  scanf("%d%d", &n, &q);
  for (int x = 1; x <= 2 * n - 2; ++x) {
    scanf("%d%d%d", &u[x], &v[x], &w[x]);
    if (v[x] != 1) adj[u[x]].push_back(v[x]);
  }
  DFS(1);
  root = BuildSegmentTree(1, n);
  PreProcess(n);
  while (q--) {
    int t, u, v;
    scanf("%d%d%d", &t, &u, &v);
    if (t == 1)
      UpdateEdge(u, v);
    else
      printf("%lld\n", Query(u, v));
  }
  return 0;
}