#include <bits/stdc++.h>
using namespace std;
template <typename T>
using V = vector<T>;
int gcdex(int a, int b, int &x, int &y) {
  if (a == 0) {
    x = 0;
    y = 1;
    return b;
  }
  int x1, y1;
  int g = gcdex(b % a, a, x1, y1);
  x = y1 - (b / a) * x1;
  y = x1;
  return g;
}
inline int ADD_MOD(int a, int b) { return (a + b) % 1000000007; }
inline int MUL_MOD(int a, int b) { return (int64_t(a) * b) % 1000000007; }
inline int SUB_MOD(int a, int b) { return a >= b ? a - b : a + 1000000007 - b; }
int DIV_MOD(int a, int b) {
  int x, y;
  gcdex(b, 1000000007, x, y);
  int b1 = (x % 1000000007 + 1000000007) % 1000000007;
  return MUL_MOD(a, b1);
}
const long double EPS = 1. / 1e9;
inline bool EPS_EQUAL(long double a, long double b) {
  return abs(a - b) <= EPS;
}
inline bool EPS_LESS(long double a, long double b) { return b - a > EPS; }
inline bool EPS_GREATER(long double a, long double b) { return a - b > EPS; }
const int INF = 1e9;
const int64_t INF64 = 2e18;
class LcaSolver {
 public:
  LcaSolver(vector<vector<int>> &tree) {
    int size = tree.size();
    timeIn.resize(size);
    timeOut.resize(size);
    parents.resize(size);
    l2N = (int)ceil(log2(size));
    for (int i = 0; i < size; ++i) {
      parents[i].resize(l2N + 1);
    }
    int timer = 0;
    dfs(tree, 0, 0, timer);
  }
  int query(int a, int b) {
    if (upper(a, b)) return a;
    if (upper(b, a)) return b;
    for (int i = l2N; i >= 0; --i) {
      if (!upper(parents[a][i], b)) {
        a = parents[a][i];
      }
    }
    return parents[a][0];
  }

 private:
  void dfs(vector<vector<int>> &tree, int node, int parent, int &timer) {
    timeIn[node] = ++timer;
    parents[node][0] = parent;
    for (int i = 1; i <= l2N; ++i) {
      parents[node][i] = parents[parents[node][i - 1]][i - 1];
    }
    for (int child : tree[node]) {
      if (child != parent) {
        dfs(tree, child, node, timer);
      }
    }
    timeOut[node] = ++timer;
  }
  bool upper(int a, int b) {
    return timeIn[a] <= timeIn[b] && timeOut[a] >= timeOut[b];
  }

 private:
  int l2N;
  vector<int> timeIn;
  vector<int> timeOut;
  vector<vector<int>> parents;
};
class HLD {
 public:
  vector<vector<int>> paths;
  vector<int> nodeToPath;
  vector<int> nodeInPath;
  vector<int> parents;
  HLD(vector<vector<int>> &graph) {
    int size = graph.size();
    vector<int> sizes(size);
    calc_subtree_sizes(graph, sizes, 0, 0);
    nodeToPath.resize(size);
    nodeInPath.resize(size);
    paths.push_back({});
    build(graph, sizes, 0, 0, 0);
    parents.resize(size);
    build_parents(graph, 0, -1);
  }
  void build(vector<vector<int>> &graph, vector<int> &sizes, int iPath,
             int node, int prev) {
    paths[iPath].push_back(node);
    nodeToPath[node] = iPath;
    nodeInPath[node] = paths[iPath].size() - 1;
    int maxChild = -1;
    int maxChildSize = 0;
    for (auto &child : graph[node]) {
      if (child != prev) {
        if (sizes[child] > maxChildSize) {
          maxChild = child;
          maxChildSize = sizes[child];
        }
      }
    }
    for (auto &child : graph[node]) {
      if (child != prev) {
        if (child == maxChild) {
          build(graph, sizes, iPath, child, node);
        } else {
          paths.push_back({});
          build(graph, sizes, paths.size() - 1, child, node);
        }
      }
    }
  }
  void build_parents(V<V<int>> &graph, int node, int parent) {
    parents[node] = parent;
    for (auto &child : graph[node]) {
      if (child != parent) {
        build_parents(graph, child, node);
      }
    }
  }
  void calc_subtree_sizes(vector<vector<int>> &graph, vector<int> &sizes,
                          int node, int prev) {
    int size = 1;
    for (auto &child : graph[node]) {
      if (child != prev) {
        calc_subtree_sizes(graph, sizes, child, node);
        size += sizes[child];
      }
    }
    sizes[node] = size;
  }
};
template <class TreeVal, class ArVal>
class SegmentTree {
 public:
  vector<TreeVal> t;
  int size;
  void build(vector<ArVal> &ar) {
    size = ar.size();
    t.resize(size * 4);
    build(0, 0, size - 1, ar);
  }
  void build(int ti, int segL, int segR, vector<ArVal> &ar) {
    if (segL == segR) {
      initLeaf(ar[segL], t[ti]);
    } else {
      int m = (segL + segR) / 2;
      int tl = left(ti);
      int tr = right(ti);
      build(tl, segL, m, ar);
      build(tr, m + 1, segR, ar);
      combine(t[tl], t[tr], t[ti]);
    }
  }
  void update(int arPos, ArVal &newVal) {
    update(0, 0, size - 1, arPos, newVal);
  }
  void update(int ti, int segL, int segR, int arPos, ArVal &newVal) {
    if (segL == segR) {
      initLeaf(newVal, t[ti]);
    } else {
      int m = (segL + segR) / 2;
      int tl = left(ti);
      int tr = right(ti);
      if (arPos <= m) {
        update(tl, segL, m, arPos, newVal);
      } else {
        update(tr, m + 1, segR, arPos, newVal);
      }
      combine(t[tl], t[tr], t[ti]);
    }
  }
  virtual void initLeaf(ArVal &val, TreeVal &res) = 0;
  virtual void combine(TreeVal &l, TreeVal &r, TreeVal &res) = 0;
  inline int left(int i) const { return i * 2 + 1; }
  inline int right(int i) const { return i * 2 + 2; }
};
int64_t mul64(int64_t a, int64_t b) {
  if (b >= INF64 / a) {
    return INF64;
  }
  return a * b;
}
class MulTree : public SegmentTree<int64_t, int64_t> {
 public:
  int64_t query(int l, int r) { return query(0, 0, size - 1, l, r); }
  int64_t query(int ti, int sl, int sr, int l, int r) {
    if (sl == l && sr == r) {
      return t[ti];
    }
    if (l > r) {
      return 1;
    }
    int m = (sl + sr) / 2;
    int64_t lval = query(left(ti), sl, m, l, min(m, r));
    int64_t rval = query(right(ti), m + 1, sr, max(l, m + 1), r);
    int64_t res;
    combine(lval, rval, res);
    return res;
  }
  virtual void initLeaf(int64_t &val, int64_t &res) { res = val; }
  virtual void combine(int64_t &l, int64_t &r, int64_t &res) {
    res = mul64(l, r);
  }
};
int64_t query(HLD &hld, V<MulTree> &pathMuls, int from, int to) {
  if (from == to) {
    return 1;
  }
  int pathFrom = hld.nodeToPath[from];
  int pathTo = hld.nodeToPath[to];
  auto &mul = pathMuls[pathFrom];
  if (pathFrom == pathTo) {
    return mul.query(hld.nodeInPath[to] + 1, hld.nodeInPath[from]);
  }
  int64_t valFrom = mul.query(0, hld.nodeInPath[from]);
  int64_t valTo = query(hld, pathMuls, hld.parents[hld.paths[pathFrom][0]], to);
  return mul64(valFrom, valTo);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(15);
  int n, m;
  cin >> n >> m;
  V<V<int>> graph(n);
  map<pair<int, int>, int> edgeIndices;
  V<int64_t> edgeCosts(n - 1);
  for (int i = 0; i < n - 1; ++i) {
    int a, b;
    int64_t cost;
    cin >> a >> b >> cost;
    --a, --b;
    graph[a].push_back(b);
    graph[b].push_back(a);
    edgeCosts[i] = cost;
    edgeIndices[{a, b}] = i;
    edgeIndices[{b, a}] = i;
  }
  LcaSolver lca(graph);
  HLD hld(graph);
  V<MulTree> pathMuls(hld.paths.size());
  V<int> edgeToPath(n - 1);
  V<int> edgeInPath(n - 1);
  for (int i = 0; i < hld.paths.size(); ++i) {
    auto &path = hld.paths[i];
    V<int64_t> pathCosts(path.size(), 1);
    pair<int, int> firstEdge = {hld.parents[path[0]], path[0]};
    if (firstEdge.first >= 0) {
      int iEdge = edgeIndices[firstEdge];
      edgeToPath[iEdge] = i;
      edgeInPath[iEdge] = 0;
      pathCosts[0] = edgeCosts[iEdge];
    }
    for (int j = 0; j < path.size() - 1; ++j) {
      pair<int, int> edge = {path[j], path[j + 1]};
      int iEdge = edgeIndices[edge];
      edgeToPath[iEdge] = i;
      edgeInPath[iEdge] = j + 1;
      pathCosts[j + 1] = edgeCosts[iEdge];
    }
    pathMuls[i].build(pathCosts);
  }
  for (int i = 0; i < m; ++i) {
    int req;
    cin >> req;
    if (req == 1) {
      int a, b;
      int64_t val;
      cin >> a >> b >> val;
      --a, --b;
      int anc = lca.query(a, b);
      int64_t vala = query(hld, pathMuls, a, anc);
      int64_t valb = query(hld, pathMuls, b, anc);
      cout << val / mul64(vala, valb) << "\n";
    } else {
      int edge;
      int64_t val;
      cin >> edge >> val;
      --edge;
      pathMuls[edgeToPath[edge]].update(edgeInPath[edge], val);
    }
  }
  return 0;
}

### Prompt

Please create a solution in cpp to the following problem:

Bogdan has a birthday today and mom gave him a tree consisting of n vertecies. For every edge of the tree i, some number xi was written on it. In case you forget, a tree is a connected non-directed graph without cycles. After the present was granted, m guests consecutively come to Bogdan's party. When the i-th guest comes, he performs exactly one of the two possible operations: 

  1. Chooses some number yi, and two vertecies ai and bi. After that, he moves along the edges of the tree from vertex ai to vertex bi using the shortest path (of course, such a path is unique in the tree). Every time he moves along some edge j, he replaces his current number yi by <image>, that is, by the result of integer division yi div xj. 
  2. Chooses some edge pi and replaces the value written in it xpi by some positive integer ci < xpi. 



As Bogdan cares about his guests, he decided to ease the process. Write a program that performs all the operations requested by guests and outputs the resulting value yi for each i of the first type.

Input

The first line of the input contains integers, n and m (2 ≤ n ≤ 200 000, 1 ≤ m ≤ 200 000) — the number of vertecies in the tree granted to Bogdan by his mom and the number of guests that came to the party respectively.

Next n - 1 lines contain the description of the edges. The i-th of these lines contains three integers ui, vi and xi (1 ≤ ui, vi ≤ n, ui ≠ vi, 1 ≤ xi ≤ 1018), denoting an edge that connects vertecies ui and vi, with the number xi initially written on it.

The following m lines describe operations, requested by Bogdan's guests. Each description contains three or four integers and has one of the two possible forms: 

  * 1 ai bi yi corresponds to a guest, who chooses the operation of the first type. 
  * 2 pi ci corresponds to a guests, who chooses the operation of the second type. 

It is guaranteed that all the queries are correct, namely 1 ≤ ai, bi ≤ n, 1 ≤ pi ≤ n - 1, 1 ≤ yi ≤ 1018 and 1 ≤ ci < xpi, where xpi represents a number written on edge pi at this particular moment of time that is not necessarily equal to the initial value xpi, as some decreases may have already been applied to it. The edges are numbered from 1 to n - 1 in the order they appear in the input.

Output

For each guest who chooses the operation of the first type, print the result of processing the value yi through the path from ai to bi.

Examples

Input

6 6
1 2 1
1 3 7
1 4 4
2 5 5
2 6 2
1 4 6 17
2 3 2
1 4 6 17
1 5 5 20
2 4 1
1 5 1 3


Output

2
4
20
3


Input

5 4
1 2 7
1 3 3
3 4 2
3 5 5
1 4 2 100
1 5 4 1
2 2 2
1 1 3 4


Output

2
0
2

Note

Initially the tree looks like this: 

<image>

The response to the first query is: <image> = 2

After the third edge is changed, the tree looks like this: 

<image>

The response to the second query is: <image> = 4

In the third query the initial and final vertex coincide, that is, the answer will be the initial number 20.

After the change in the fourth edge the tree looks like this: 

<image>

In the last query the answer will be: <image> = 3

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using V = vector<T>;
int gcdex(int a, int b, int &x, int &y) {
  if (a == 0) {
    x = 0;
    y = 1;
    return b;
  }
  int x1, y1;
  int g = gcdex(b % a, a, x1, y1);
  x = y1 - (b / a) * x1;
  y = x1;
  return g;
}
inline int ADD_MOD(int a, int b) { return (a + b) % 1000000007; }
inline int MUL_MOD(int a, int b) { return (int64_t(a) * b) % 1000000007; }
inline int SUB_MOD(int a, int b) { return a >= b ? a - b : a + 1000000007 - b; }
int DIV_MOD(int a, int b) {
  int x, y;
  gcdex(b, 1000000007, x, y);
  int b1 = (x % 1000000007 + 1000000007) % 1000000007;
  return MUL_MOD(a, b1);
}
const long double EPS = 1. / 1e9;
inline bool EPS_EQUAL(long double a, long double b) {
  return abs(a - b) <= EPS;
}
inline bool EPS_LESS(long double a, long double b) { return b - a > EPS; }
inline bool EPS_GREATER(long double a, long double b) { return a - b > EPS; }
const int INF = 1e9;
const int64_t INF64 = 2e18;
class LcaSolver {
 public:
  LcaSolver(vector<vector<int>> &tree) {
    int size = tree.size();
    timeIn.resize(size);
    timeOut.resize(size);
    parents.resize(size);
    l2N = (int)ceil(log2(size));
    for (int i = 0; i < size; ++i) {
      parents[i].resize(l2N + 1);
    }
    int timer = 0;
    dfs(tree, 0, 0, timer);
  }
  int query(int a, int b) {
    if (upper(a, b)) return a;
    if (upper(b, a)) return b;
    for (int i = l2N; i >= 0; --i) {
      if (!upper(parents[a][i], b)) {
        a = parents[a][i];
      }
    }
    return parents[a][0];
  }

 private:
  void dfs(vector<vector<int>> &tree, int node, int parent, int &timer) {
    timeIn[node] = ++timer;
    parents[node][0] = parent;
    for (int i = 1; i <= l2N; ++i) {
      parents[node][i] = parents[parents[node][i - 1]][i - 1];
    }
    for (int child : tree[node]) {
      if (child != parent) {
        dfs(tree, child, node, timer);
      }
    }
    timeOut[node] = ++timer;
  }
  bool upper(int a, int b) {
    return timeIn[a] <= timeIn[b] && timeOut[a] >= timeOut[b];
  }

 private:
  int l2N;
  vector<int> timeIn;
  vector<int> timeOut;
  vector<vector<int>> parents;
};
class HLD {
 public:
  vector<vector<int>> paths;
  vector<int> nodeToPath;
  vector<int> nodeInPath;
  vector<int> parents;
  HLD(vector<vector<int>> &graph) {
    int size = graph.size();
    vector<int> sizes(size);
    calc_subtree_sizes(graph, sizes, 0, 0);
    nodeToPath.resize(size);
    nodeInPath.resize(size);
    paths.push_back({});
    build(graph, sizes, 0, 0, 0);
    parents.resize(size);
    build_parents(graph, 0, -1);
  }
  void build(vector<vector<int>> &graph, vector<int> &sizes, int iPath,
             int node, int prev) {
    paths[iPath].push_back(node);
    nodeToPath[node] = iPath;
    nodeInPath[node] = paths[iPath].size() - 1;
    int maxChild = -1;
    int maxChildSize = 0;
    for (auto &child : graph[node]) {
      if (child != prev) {
        if (sizes[child] > maxChildSize) {
          maxChild = child;
          maxChildSize = sizes[child];
        }
      }
    }
    for (auto &child : graph[node]) {
      if (child != prev) {
        if (child == maxChild) {
          build(graph, sizes, iPath, child, node);
        } else {
          paths.push_back({});
          build(graph, sizes, paths.size() - 1, child, node);
        }
      }
    }
  }
  void build_parents(V<V<int>> &graph, int node, int parent) {
    parents[node] = parent;
    for (auto &child : graph[node]) {
      if (child != parent) {
        build_parents(graph, child, node);
      }
    }
  }
  void calc_subtree_sizes(vector<vector<int>> &graph, vector<int> &sizes,
                          int node, int prev) {
    int size = 1;
    for (auto &child : graph[node]) {
      if (child != prev) {
        calc_subtree_sizes(graph, sizes, child, node);
        size += sizes[child];
      }
    }
    sizes[node] = size;
  }
};
template <class TreeVal, class ArVal>
class SegmentTree {
 public:
  vector<TreeVal> t;
  int size;
  void build(vector<ArVal> &ar) {
    size = ar.size();
    t.resize(size * 4);
    build(0, 0, size - 1, ar);
  }
  void build(int ti, int segL, int segR, vector<ArVal> &ar) {
    if (segL == segR) {
      initLeaf(ar[segL], t[ti]);
    } else {
      int m = (segL + segR) / 2;
      int tl = left(ti);
      int tr = right(ti);
      build(tl, segL, m, ar);
      build(tr, m + 1, segR, ar);
      combine(t[tl], t[tr], t[ti]);
    }
  }
  void update(int arPos, ArVal &newVal) {
    update(0, 0, size - 1, arPos, newVal);
  }
  void update(int ti, int segL, int segR, int arPos, ArVal &newVal) {
    if (segL == segR) {
      initLeaf(newVal, t[ti]);
    } else {
      int m = (segL + segR) / 2;
      int tl = left(ti);
      int tr = right(ti);
      if (arPos <= m) {
        update(tl, segL, m, arPos, newVal);
      } else {
        update(tr, m + 1, segR, arPos, newVal);
      }
      combine(t[tl], t[tr], t[ti]);
    }
  }
  virtual void initLeaf(ArVal &val, TreeVal &res) = 0;
  virtual void combine(TreeVal &l, TreeVal &r, TreeVal &res) = 0;
  inline int left(int i) const { return i * 2 + 1; }
  inline int right(int i) const { return i * 2 + 2; }
};
int64_t mul64(int64_t a, int64_t b) {
  if (b >= INF64 / a) {
    return INF64;
  }
  return a * b;
}
class MulTree : public SegmentTree<int64_t, int64_t> {
 public:
  int64_t query(int l, int r) { return query(0, 0, size - 1, l, r); }
  int64_t query(int ti, int sl, int sr, int l, int r) {
    if (sl == l && sr == r) {
      return t[ti];
    }
    if (l > r) {
      return 1;
    }
    int m = (sl + sr) / 2;
    int64_t lval = query(left(ti), sl, m, l, min(m, r));
    int64_t rval = query(right(ti), m + 1, sr, max(l, m + 1), r);
    int64_t res;
    combine(lval, rval, res);
    return res;
  }
  virtual void initLeaf(int64_t &val, int64_t &res) { res = val; }
  virtual void combine(int64_t &l, int64_t &r, int64_t &res) {
    res = mul64(l, r);
  }
};
int64_t query(HLD &hld, V<MulTree> &pathMuls, int from, int to) {
  if (from == to) {
    return 1;
  }
  int pathFrom = hld.nodeToPath[from];
  int pathTo = hld.nodeToPath[to];
  auto &mul = pathMuls[pathFrom];
  if (pathFrom == pathTo) {
    return mul.query(hld.nodeInPath[to] + 1, hld.nodeInPath[from]);
  }
  int64_t valFrom = mul.query(0, hld.nodeInPath[from]);
  int64_t valTo = query(hld, pathMuls, hld.parents[hld.paths[pathFrom][0]], to);
  return mul64(valFrom, valTo);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(15);
  int n, m;
  cin >> n >> m;
  V<V<int>> graph(n);
  map<pair<int, int>, int> edgeIndices;
  V<int64_t> edgeCosts(n - 1);
  for (int i = 0; i < n - 1; ++i) {
    int a, b;
    int64_t cost;
    cin >> a >> b >> cost;
    --a, --b;
    graph[a].push_back(b);
    graph[b].push_back(a);
    edgeCosts[i] = cost;
    edgeIndices[{a, b}] = i;
    edgeIndices[{b, a}] = i;
  }
  LcaSolver lca(graph);
  HLD hld(graph);
  V<MulTree> pathMuls(hld.paths.size());
  V<int> edgeToPath(n - 1);
  V<int> edgeInPath(n - 1);
  for (int i = 0; i < hld.paths.size(); ++i) {
    auto &path = hld.paths[i];
    V<int64_t> pathCosts(path.size(), 1);
    pair<int, int> firstEdge = {hld.parents[path[0]], path[0]};
    if (firstEdge.first >= 0) {
      int iEdge = edgeIndices[firstEdge];
      edgeToPath[iEdge] = i;
      edgeInPath[iEdge] = 0;
      pathCosts[0] = edgeCosts[iEdge];
    }
    for (int j = 0; j < path.size() - 1; ++j) {
      pair<int, int> edge = {path[j], path[j + 1]};
      int iEdge = edgeIndices[edge];
      edgeToPath[iEdge] = i;
      edgeInPath[iEdge] = j + 1;
      pathCosts[j + 1] = edgeCosts[iEdge];
    }
    pathMuls[i].build(pathCosts);
  }
  for (int i = 0; i < m; ++i) {
    int req;
    cin >> req;
    if (req == 1) {
      int a, b;
      int64_t val;
      cin >> a >> b >> val;
      --a, --b;
      int anc = lca.query(a, b);
      int64_t vala = query(hld, pathMuls, a, anc);
      int64_t valb = query(hld, pathMuls, b, anc);
      cout << val / mul64(vala, valb) << "\n";
    } else {
      int edge;
      int64_t val;
      cin >> edge >> val;
      --edge;
      pathMuls[edgeToPath[edge]].update(edgeInPath[edge], val);
    }
  }
  return 0;
}

```