#include <bits/stdc++.h>
using namespace std;
long long z, dis[1000000], Dis[1000000];
int u, v, w, x, y, tot, from[1000000], to[1000000];
int nex[1000000], head[1000000], fu[1000000];
int n, m, son, k, dep[1000000], f[300000][30], lg[1000000], t;
void add(int u, int v, long long w) {
  tot++;
  from[tot] = u;
  to[tot] = v;
  dis[tot] = w;
  nex[tot] = head[u];
  head[u] = tot;
}
int find(int x) {
  if (fu[x] != x)
    return fu[x] = find(fu[x]);
  else
    return x;
}
void dfs(int u, int fa) {
  dep[u] = dep[fa] + 1;
  f[u][0] = fa;
  for (int i = 1; i <= lg[dep[u]]; i++) f[u][i] = f[f[u][i - 1]][i - 1];
  for (int i = head[u]; i; i = nex[i]) {
    int v = to[i];
    long long w = dis[i];
    if (v != fa) {
      if (w == 1) fu[v] = find(u);
      Dis[v] = w;
      dfs(v, u);
    }
  }
}
long long lca(int a, int b) {
  if (dep[a] > dep[b]) swap(a, b);
  while (dep[b] > dep[a]) b = f[b][lg[dep[b] - dep[a]]];
  if (a == b) return a;
  for (int i = lg[dep[a]]; i >= 0; i--)
    if (f[a][i] != f[b][i]) {
      a = f[a][i];
      b = f[b][i];
    }
  return f[a][0];
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) fu[i] = i;
  for (int i = 1; i <= n; i++) lg[i] = lg[i - 1] + (1 << lg[i - 1] == i);
  for (int i = 1; i <= n; i++) lg[i]--;
  for (int i = 1; i < n; i++) {
    scanf("%d%d%lld", &x, &y, &z);
    add(x, y, z);
    add(y, x, z);
  }
  dfs(1, 0);
  for (int i = 1; i <= m; i++) {
    scanf("%d", &t);
    if (t == 1) {
      scanf("%d%d%lld", &x, &y, &z);
      int Lca = lca(x, y);
      while (dep[x] > dep[Lca] && z) {
        z /= Dis[x];
        x = find(f[x][0]);
      }
      while (dep[y] > dep[Lca] && z) {
        z /= Dis[y];
        y = find(f[y][0]);
      }
      printf("%lld\n", z);
    } else {
      scanf("%d%lld", &k, &z);
      int u = from[k << 1], v = to[k << 1];
      if (f[u][0] == v)
        son = u;
      else
        son = v;
      Dis[son] = z;
      if (Dis[son] == 1) fu[son] = find(f[son][0]);
    }
  }
  return 0;
}
