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>
const int max_n = 210000;
const int tree_size = 1 << 20;
const long long inf = 1000000000000000000LL;
int n, q;
std::vector<std::pair<int, int> > T[max_n];
int in[max_n], out[max_n];
int first_group[max_n];
int second_group[max_n];
int cost_back[max_n];
int cost_tree[max_n];
long long initial_path_cost[max_n];
long long root_cost_tree[tree_size];
long long back_cost_tree[tree_size];
long long root_cost_tree_mod[tree_size];
long long back_cost_tree_mod[tree_size];
void init_trees() {
  int czapa = 1;
  while (czapa <= 2 * n) czapa += czapa;
  for (int i = 0; i < 2 * czapa; ++i) {
    root_cost_tree[i] = inf;
    back_cost_tree[i] = inf;
    root_cost_tree_mod[i] = 0;
    back_cost_tree_mod[i] = 0;
  }
}
long long compute_min(long long tree[], long long tree_mod[], int node,
                      int range_begin, int range_end, int query_begin,
                      int query_end) {
  if (range_begin == query_begin && range_end == query_end) {
    return tree[node] + tree_mod[node];
  } else {
    int middle = (range_begin + range_end) / 2;
    tree_mod[node + node] += tree_mod[node];
    tree_mod[node + node + 1] += tree_mod[node];
    tree_mod[node] = 0;
    long long answer = inf;
    if (query_begin <= middle) {
      long long r1 =
          compute_min(tree, tree_mod, node + node, range_begin, middle,
                      query_begin, std::min(query_end, middle));
      answer = std::min(answer, r1);
    }
    if (query_end > middle) {
      long long r2 =
          compute_min(tree, tree_mod, node + node + 1, middle + 1, range_end,
                      std::max(query_begin, middle + 1), query_end);
      answer = std::min(answer, r2);
    }
    tree[node] = std::min(tree[node + node] + tree_mod[node + node],
                          tree[node + node + 1] + tree_mod[node + node + 1]);
    return answer;
  }
}
void update_range(long long tree[], long long tree_mod[], int node,
                  int range_begin, int range_end, int query_begin,
                  int query_end, long long mod) {
  if (range_begin == query_begin && range_end == query_end) {
    tree_mod[node] += mod;
  } else {
    int middle = (range_begin + range_end) / 2;
    tree_mod[node + node] += tree_mod[node];
    tree_mod[node + node + 1] += tree_mod[node];
    tree_mod[node] = 0;
    if (query_begin <= middle) {
      update_range(tree, tree_mod, node + node, range_begin, middle,
                   query_begin, std::min(middle, query_end), mod);
    }
    if (query_end > middle) {
      update_range(tree, tree_mod, node + node + 1, middle + 1, range_end,
                   std::max(query_begin, middle + 1), query_end, mod);
    }
    tree[node] = std::min(tree[node + node] + tree_mod[node + node],
                          tree[node + node + 1] + tree_mod[node + node + 1]);
  }
}
void update_back_cost_tree(int begin, int end, long long change) {
  return update_range(back_cost_tree, back_cost_tree_mod, 1, 0, n - 1, begin,
                      end, change);
}
long long get_back_cost_tree(int begin, int end) {
  return compute_min(back_cost_tree, back_cost_tree_mod, 1, 0, n - 1, begin,
                     end);
}
void update_root_cost_tree(int begin, int end, long long change) {
  return update_range(root_cost_tree, root_cost_tree_mod, 1, 0, n - 1, begin,
                      end, change);
}
long long get_root_cost_tree(int elem) {
  return compute_min(root_cost_tree, root_cost_tree_mod, 1, 0, n - 1, elem,
                     elem);
}
void dfs(int v, long long c, int &time_step) {
  in[v] = time_step++;
  initial_path_cost[v] = c;
  for (int i = 0; i < T[v].size(); ++i) {
    dfs(T[v][i].first, c + T[v][i].second, time_step);
  }
  out[v] = time_step - 1;
}
void read_input() {
  cost_back[0] = 0;
  for (int i = 0; i < n - 1; ++i) {
    int u, v, c;
    std::cin >> u >> v >> c;
    --u;
    --v;
    first_group[i] = v;
    cost_tree[i] = c;
    T[u].push_back(std::make_pair(v, c));
  }
  for (int i = 0; i < n - 1; ++i) {
    int u, v, c;
    std::cin >> u >> v >> c;
    --u;
    --v;
    second_group[i] = u;
    cost_back[u] = c;
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin >> n >> q;
  init_trees();
  read_input();
  int time_step = 0;
  dfs(0, 0, time_step);
  for (int i = 0; i < n; ++i) {
    update_back_cost_tree(in[i], in[i], cost_back[i] - inf);
    update_back_cost_tree(in[i], in[i], initial_path_cost[i]);
    update_root_cost_tree(in[i], in[i], initial_path_cost[i] - inf);
  }
  for (int i = 0; i < q; ++i) {
    int query_type, u, v;
    std::cin >> query_type >> u >> v;
    if (query_type == 1) {
      --u;
      if (u >= n - 1) {
        u -= n - 1;
        int vertex = second_group[u];
        update_back_cost_tree(in[vertex], in[vertex], v - cost_back[vertex]);
        cost_back[vertex] = v;
      } else {
        int vertex = first_group[u];
        update_root_cost_tree(in[vertex], out[vertex], v - cost_tree[u]);
        update_back_cost_tree(in[vertex], out[vertex], v - cost_tree[u]);
        cost_tree[u] = v;
      }
    } else {
      --u;
      --v;
      if (in[u] <= in[v] && out[v] <= out[u]) {
        std::cout << get_root_cost_tree(in[v]) - get_root_cost_tree(in[u])
                  << std::endl;
      } else {
        std::cout << get_root_cost_tree(in[v]) - get_root_cost_tree(in[u]) +
                         get_back_cost_tree(in[u], out[u])
                  << std::endl;
      }
    }
  }
  return 0;
}