#include <bits/stdc++.h>
using namespace std;
long long tot, n, q, u, v, z, a, b, c, p, k;
long long dep[200005], f[200005][25], fa[200005], va[200005];
struct edge {
  long long from, head, nxt, val, go;
} e[200005 * 4];
long long find(long long x) {
  long long o = x;
  while (x != fa[x]) x = fa[x] = fa[fa[x]];
  while (o != x) {
    long long j = fa[o];
    fa[o] = x;
    o = j;
  }
  return x;
}
void add(long long u, long long v, long long z) {
  e[++tot].nxt = e[u].head;
  e[u].head = tot;
  e[tot].from = u;
  e[tot].go = v;
  e[tot].val = z;
}
void deal_first(long long u, long long father) {
  dep[u] = dep[father] + 1;
  for (int i = 0; i <= 19; i++) f[u][i + 1] = f[f[u][i]][i];
  for (long long i = e[u].head; i; i = e[i].nxt) {
    long long v = e[i].go, w = e[i].val;
    if (v == father) continue;
    if (w == 1) fa[v] = find(u);
    va[v] = w;
    f[v][0] = u;
    deal_first(v, u);
  }
}
long long lca(long long u, long long v) {
  if (dep[u] < dep[v]) swap(u, v);
  for (long long i = 17; i >= 0; i--) {
    if (dep[f[u][i]] >= dep[v]) u = f[u][i];
    if (u == v) return u;
  }
  for (long long i = 17; i >= 0; i--) {
    if (f[u][i] != f[v][i]) {
      u = f[u][i];
      v = f[v][i];
    }
  }
  return f[u][0];
}
int main() {
  scanf("%lld%lld", &n, &q);
  for (int i = 1; i < n; i++) {
    scanf("%lld%lld%lld", &u, &v, &z);
    add(u, v, z);
    add(v, u, z);
  }
  for (int i = 1; i <= n; i++) fa[i] = i;
  deal_first(1, 0);
  while (q--) {
    scanf("%lld", &k);
    if (k == 1) {
      scanf("%lld%lld%lld", &a, &b, &c);
      long long finish = lca(a, b);
      while (dep[a] > dep[finish] && c) {
        c = c / va[a];
        a = find(f[a][0]);
      }
      while (dep[b] > dep[finish] && c) {
        c = c / va[b];
        b = find(f[b][0]);
      }
      printf("%lld\n", c);
    } else {
      scanf("%lld%lld", &p, &c);
      long long u = e[p << 1].from, v = e[p << 1].go;
      if (f[u][0] == v)
        z = u;
      else
        z = v;
      va[z] = c;
      if (va[z] == 1) fa[z] = find(f[z][0]);
    }
  }
}
