#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
using namespace std;
void desperate_optimization(int precision) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout.setf(ios::fixed);
  cout.setf(ios::showpoint);
  cout.precision(precision);
}
const int N = 2e5;
int idchain, chain;
int LCA[22][N + 5];
int depth[N + 5];
int par[N + 5];
long long val[N + 5];
vector<pair<int, int> > edges;
vector<pair<int, long long> > vec[N + 5];
int find(int x) {
  if (x == par[x]) return x;
  return par[x] = find(par[x]);
}
void dfs(int idx, int pre, int h) {
  depth[idx] = h;
  LCA[0][idx] = pre;
  for (int i = 0; i < vec[idx].size(); i++) {
    int nx = vec[idx][i].first;
    if (nx == pre) continue;
    val[nx] = vec[idx][i].second;
    if (val[nx] == 1) par[nx] = find(par[idx]);
    dfs(nx, idx, h + 1);
  }
}
int po[22];
int LC(int u, int v) {
  if (depth[u] < depth[v]) swap(u, v);
  int diff = depth[u] - depth[v];
  for (int i = 20; i >= 0; i--) {
    if (diff & po[i]) u = LCA[i][u];
  }
  if (u == v) return u;
  for (int i = 20; i >= 0; i--) {
    if (LCA[i][u] != LCA[i][v]) {
      u = LCA[i][u], v = LCA[i][v];
    }
  }
  return LCA[0][u];
}
long long query(int idx, int tar, long long v) {
  if (v == 0) return 0;
  while (1) {
    idx = find(par[idx]);
    if (depth[LCA[0][idx]] >= depth[tar]) {
      v /= val[idx];
      idx = LCA[0][idx];
    } else
      break;
    if (v == 0) return 0;
  }
  return v;
}
long long querycheck(int u, int v, long long y) {
  int w = LC(u, v);
  long long lhs = query(u, w, y);
  long long rhs = query(v, w, lhs);
  return rhs;
}
void hora(int tc) {
  po[0] = 1;
  for (int i = 1; i <= 20; i++) po[i] = po[i - 1] * 2;
  int n, q;
  scanf("%d%d", &n, &q);
  for (int i = 1; i <= n; i++) par[i] = i;
  for (int i = 1; i < n; i++) {
    int u, v;
    long long q;
    scanf("%d%d%lld", &u, &v, &q);
    vec[u].push_back({v, q});
    vec[v].push_back({u, q});
    edges.push_back({u, v});
  }
  val[1] = 1, par[1] = 0;
  dfs(1, 0, 1);
  for (int i = 1; i <= 20; i++)
    for (int j = 1; j <= n; j++) LCA[i][j] = LCA[i - 1][LCA[i - 1][j]];
  while (q--) {
    int type;
    scanf("%d", &type);
    if (type == 1) {
      int a, b;
      long long y;
      scanf("%d%d%lld", &a, &b, &y);
      long long res = querycheck(a, b, y);
      printf("%lld\n", res);
    } else {
      int p;
      long long c;
      scanf("%d%lld", &p, &c);
      int uu = edges[p - 1].first;
      int vv = edges[p - 1].second;
      if (depth[uu] > depth[vv]) swap(uu, vv);
      val[vv] = c;
      if (val[vv] == 1) {
        par[vv] = find(par[uu]);
      }
    }
  }
}
int main() {
  int ntc = 1;
  for (int tc = 1; tc <= ntc; tc++) hora(tc);
  return 0;
}
