#include <bits/stdc++.h>
using namespace std;
int n, m, tot, cnt, siz[200010], dep[200010], fa[200010], top[200010],
    dfn[200010], rk[200010], son[200010], head[200010], ver[200010 * 2],
    bel[200010 * 2], Next[200010 * 2];
long long a[200010], edge[200010 * 2];
long double tr[200010 * 4];
void add_edge(int u, int v, long long w) {
  ver[++tot] = v;
  edge[tot] = w;
  Next[tot] = head[u];
  head[u] = tot;
}
void dfs1(int u) {
  siz[u] = 1;
  dep[u] = dep[fa[u]] + 1;
  for (int i = head[u]; i; i = Next[i]) {
    int v = ver[i];
    if (v == fa[u]) continue;
    bel[i] = bel[i ^ 1] = v;
    a[v] = edge[i];
    fa[v] = u;
    dfs1(v);
    siz[u] += siz[v];
    if (siz[son[u]] < siz[v]) son[u] = v;
  }
}
void dfs2(int u, int Top) {
  top[u] = Top;
  dfn[u] = ++cnt;
  rk[cnt] = u;
  if (son[u]) dfs2(son[u], Top);
  for (int i = head[u]; i; i = Next[i]) {
    int v = ver[i];
    if (v == fa[u] || v == son[u]) continue;
    dfs2(v, v);
  }
}
void build(int p, int L, int R) {
  if (L == R) {
    tr[p] = (long double)a[rk[L]];
    return;
  }
  int mid = (L + R) >> 1;
  build(p << 1, L, mid);
  build(p << 1 | 1, mid + 1, R);
  tr[p] = tr[p << 1] * tr[p << 1 | 1];
  if (tr[p] > 1e18) tr[p] = 0;
}
void modify(int p, int L, int R, int pos, long long w) {
  if (L == R) {
    tr[p] = (long double)w;
    return;
  }
  int mid = (L + R) >> 1;
  if (pos <= mid)
    modify(p << 1, L, mid, pos, w);
  else
    modify(p << 1 | 1, mid + 1, R, pos, w);
  tr[p] = tr[p << 1] * tr[p << 1 | 1];
  if (tr[p] > 1e18) tr[p] = 0;
}
long double query(int p, int L, int R, int l, int r) {
  if (l <= L && R <= r) return tr[p];
  int mid = (L + R) >> 1;
  long double res = 1.0;
  if (l <= mid) res = res * query(p << 1, L, mid, l, r);
  if (r > mid) res = res * query(p << 1 | 1, mid + 1, R, l, r);
  if (res > 1e18) res = 0;
  return res;
}
long double Query(int u, int v) {
  long double res = 1.0;
  while (top[u] != top[v]) {
    if (dep[top[u]] < dep[top[v]]) swap(u, v);
    res = res * query(1, 1, n, dfn[top[u]], dfn[u]);
    if (res > 1e18) res = 0;
    u = fa[top[u]];
  }
  if (dfn[u] > dfn[v]) swap(u, v);
  res = res * query(1, 1, n, dfn[u] + 1, dfn[v]);
  if (res > 1e18) res = 0;
  return res;
}
int main() {
  scanf("%d%d", &n, &m);
  tot = 1;
  for (int i = 1; i < n; i++) {
    int u, v;
    long long w;
    scanf("%d%d%lld", &u, &v, &w);
    add_edge(u, v, w);
    add_edge(v, u, w);
  }
  dfs1(1);
  dfs2(1, 1);
  a[1] = 1.0;
  build(1, 1, n);
  while (m--) {
    int op, u, v;
    long long w;
    long double tmp;
    scanf("%d%d", &op, &u);
    if (op == 1) {
      scanf("%d%lld", &v, &w);
      tmp = Query(u, v);
      if (tmp == 0)
        puts("0");
      else
        printf("%lld\n", (long long)(w / tmp));
    }
    if (op == 2) {
      scanf("%lld", &w);
      modify(1, 1, n, dfn[bel[u * 2]], w);
    }
  }
  return 0;
}
