#include <bits/stdc++.h>
const int N = 2e5 + 5, M = 4e5 + 5;
int n, m, tot, lnk[N], sta[M], ter[M], nxt[M], up[N], fa[N], f[N], dep[N];
long long val[M];
void add(int u, int v, long long w) {
  ter[++tot] = v, sta[tot] = u, nxt[tot] = lnk[u], lnk[u] = tot, val[tot] = w;
}
int find(int x) { return f[x] == x ? x : f[x] = find(f[x]); }
void merge(int u, int v) { f[find(u)] = find(v); }
void dfs(int u, int p) {
  for (int i = lnk[u]; i; i = nxt[i]) {
    int v = ter[i];
    if (v == p) continue;
    fa[v] = u, up[v] = i, dep[v] = dep[u] + 1;
    if (val[i] == 1) {
      merge(v, u);
      dep[v] = dep[find(v)];
    }
    dfs(v, u);
  }
}
long long query(int u, int v) {
  long long ans = 1;
  for (; (u = find(u)) != (v = find(v)); u = fa[u]) {
    if (dep[u] < dep[v]) {
      std::swap(u, v);
    }
    if (ans > 1e18 / val[up[u]]) {
      return 0;
    }
    ans *= val[up[u]];
  }
  return ans;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i < n; i++) {
    int u, v;
    long long w;
    scanf("%d%d%lld", &u, &v, &w);
    add(u, v, w), add(v, u, w);
  }
  for (int i = 1; i <= n; i++) {
    f[i] = i;
  }
  dep[1] = 1;
  dfs(1, 0);
  for (int i = 1; i <= m; i++) {
    int opt;
    scanf("%d", &opt);
    if (opt == 1) {
      int u, v;
      long long w;
      scanf("%d%d%lld", &u, &v, &w);
      long long ans = query(u, v);
      printf("%lld\n", ans ? w / ans : 0);
    } else {
      int x;
      long long w;
      scanf("%d%lld", &x, &w);
      x <<= 1;
      val[x - 1] = val[x] = w;
      if (w == 1) {
        int u = find(sta[x]), v = find(ter[x]);
        if (dep[u] > dep[v]) {
          std::swap(u, v);
        }
        merge(v, u);
        dep[v] = dep[find(v)];
      }
    }
  }
  return 0;
}
