#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int firste[N], nexte[N << 1], v[N << 1];
long long w[N << 1];
int fa[N], d[N], aim[N], fa2[N];
long long dist[N];
int n, m, e = 1;
void build_edge(int x, int y, long long z) {
  nexte[++e] = firste[x];
  firste[x] = e;
  v[e] = y;
  w[e] = z;
}
int findf(int x) {
  if (fa2[x] == x) return x;
  return fa2[x] = findf(fa2[x]);
}
void dfs(int u) {
  for (int p = firste[u]; p; p = nexte[p])
    if (!fa[v[p]]) {
      aim[p / 2] = v[p];
      fa[v[p]] = u;
      d[v[p]] = d[u] + 1;
      dist[v[p]] = w[p];
      if (w[p] == 1) fa2[v[p]] = findf(u);
      dfs(v[p]);
    }
}
long long check(int x, int y, long long z) {
  while (x != y) {
    if (d[x] < d[y]) swap(x, y);
    if (dist[x] == 1)
      x = findf(x);
    else {
      z /= dist[x];
      x = fa[x];
      if (!z) return z;
    }
  }
  return z;
}
int main() {
  scanf("%d%d", &n, &m);
  int x, y;
  long long z;
  for (int i = 1; i < n; ++i) {
    scanf("%d%d%lld", &x, &y, &z);
    build_edge(x, y, z);
    build_edge(y, x, z);
  }
  fa[1] = 1;
  dist[1] = 1;
  for (int i = 1; i <= n; ++i) fa2[i] = i;
  dfs(1);
  while (m--) {
    scanf("%d", &x);
    if (x & 1) {
      scanf("%d%d%lld", &x, &y, &z);
      printf("%lld\n", check(x, y, z));
    } else {
      scanf("%d%lld", &x, &z);
      int u = aim[x];
      dist[u] = z;
      if (z == 1) fa2[u] = findf(fa[u]);
    }
  }
  return 0;
}
