#include <bits/stdc++.h>
using namespace std;
int n, m, q;
struct dian {
  int x, y;
  long long z;
} d[1000000 * 2];
struct tu {
  int v, nxt, u, id;
} e[1000000 * 2];
int head[1000000], cnt, tot, dep[1000000];
int pos[1000000];
long long val[1000000];
int f[1000000];
int bcj[1000000];
int find(int x) {
  if (x == bcj[x]) return x;
  bcj[x] = find(bcj[x]);
  return bcj[x];
}
void add(int u, int v, int id) {
  e[++cnt].v = v;
  e[cnt].id = id;
  e[cnt].nxt = head[u];
  head[u] = cnt;
}
void pushup(int u, int v) {
  pos[v] = pos[u];
  f[v] = f[u];
}
void dfs(int u, int fa) {
  dep[u] = dep[fa] + 1;
  for (register int i = head[u]; i; i = e[i].nxt) {
    int v = e[i].v;
    if (v == fa) continue;
    f[v] = u;
    pos[v] = e[i].id;
    if (val[e[i].id] == 1) {
      bcj[v] = find(u);
      pushup(u, v);
    }
    dfs(v, u);
  }
}
long long lca(int u, int v, long long mul) {
  u = find(u);
  v = find(v);
  while (u != v) {
    if (dep[u] < dep[v]) swap(u, v);
    mul /= val[pos[u]];
    if (mul == 0) return mul;
    u = find(f[u]);
  }
  return mul;
}
int main() {
  scanf("%d%d", &n, &q);
  for (register int i = 0; i <= n; i++) bcj[i] = i;
  for (register int i = 1; i <= n - 1; i++) {
    int a1, a2, a3;
    scanf("%d%d%I64d", &a1, &a2, &val[i]);
    add(a1, a2, i);
    add(a2, a1, i);
    d[i] = (dian){a1, a2, val[i]};
  }
  val[0] = 1;
  pos[1] = 0;
  f[1] = 1;
  dfs(1, 0);
  for (register int i = 1; i <= q; i++) {
    int a1, a2;
    long long a4, a3;
    scanf("%d", &a1);
    if (a1 == 1) {
      scanf("%d%I64d%I64d", &a2, &a3, &a4);
      long long ans = lca(a2, a3, a4);
      printf("%I64d\n", ans);
    } else {
      scanf("%d%I64d", &a2, &a3);
      val[a2] = a3;
      int x = d[a2].x;
      int y = d[a2].y;
      if (dep[x] < dep[y]) swap(x, y);
      if (val[a2] == 1) {
        bcj[x] = find(y);
        pos[x] = pos[y];
        f[x] = f[y];
      }
    }
  }
  return 0;
}
