#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int n, m, cnt, ind;
int b[200005 << 1], p[200005], nextedge[200005 << 1];
long long w[200005 << 1];
int sz[200005], deep[200005], fa[200005], son[200005], top[200005], pos[200005],
    ftree[200005];
long long a[200005];
struct node {
  int l, r;
  long long mul;
} e[200005 << 2];
void add(int x, int y, long long z) {
  cnt++;
  b[cnt] = y;
  nextedge[cnt] = p[x];
  p[x] = cnt;
  w[cnt] = z;
}
void dfs1(int x) {
  sz[x] = 1;
  for (int i = p[x]; i; i = nextedge[i]) {
    int v = b[i];
    if (fa[x] == v) continue;
    fa[v] = x;
    deep[v] = deep[x] + 1;
    dfs1(v);
    sz[x] += sz[v];
    son[x] = sz[son[x]] < sz[v] ? v : son[x];
  }
}
void dfs2(int x, int root) {
  pos[x] = ++ind;
  top[x] = root;
  ftree[pos[x]] = x;
  if (son[x]) dfs2(son[x], root);
  for (int i = p[x]; i; i = nextedge[i]) {
    int v = b[i];
    if (v == fa[x] || v == son[x]) continue;
    dfs2(v, v);
  }
}
long long MUL(long long x, long long y) {
  if (x == 0 || y == 0) return 0;
  if (1e18 / x < y) return 0;
  return x * y;
}
void pushup(int p) { e[p].mul = MUL(e[p << 1].mul, e[p << 1 | 1].mul); }
void build(int p, int l, int r) {
  e[p].l = l, e[p].r = r, e[p].mul = 1;
  if (l == r) {
    e[p].mul = a[ftree[l]];
    return;
  }
  int mid = l + r >> 1;
  build(p << 1, l, mid);
  build(p << 1 | 1, mid + 1, r);
  pushup(p);
}
long long querysum(int p, int x, int y) {
  int l = e[p].l, r = e[p].r, mid = l + r >> 1;
  if (l >= x && y >= r) return e[p].mul;
  if (y <= mid) return querysum(p << 1, x, y);
  if (x > mid) return querysum(p << 1 | 1, x, y);
  return MUL(querysum(p << 1, x, mid), querysum(p << 1 | 1, mid + 1, y));
}
long long query(int x, int y) {
  long long sum = 1;
  int fx = top[x], fy = top[y];
  while (fx != fy) {
    if (deep[fx] < deep[fy]) swap(x, y), swap(fx, fy);
    sum = MUL(sum, querysum(1, pos[fx], pos[x]));
    x = fa[fx], fx = top[x];
  }
  if (deep[x] > deep[y]) swap(x, y);
  if (x != y) sum = MUL(sum, querysum(1, pos[x] + 1, pos[y]));
  return sum;
}
void change(int p, int x, long long y) {
  int l = e[p].l, r = e[p].r, mid = l + r >> 1;
  if (l == r && l == x) {
    e[p].mul = y;
    return;
  }
  if (x <= mid)
    change(p << 1, x, y);
  else
    change(p << 1 | 1, x, y);
  pushup(p);
}
int main() {
  n = read(), m = read();
  static int f, x, y;
  long long z, zz;
  for (int i = 1; i < n; i++) {
    x = read(), y = read(), z = read();
    add(x, y, z);
    add(y, x, z);
  }
  dfs1(1);
  dfs2(1, 1);
  for (int i = 1; i < cnt; i += 2) {
    x = b[i], y = b[i + 1];
    if (deep[x] < deep[y]) swap(x, y);
    a[x] = w[i];
  }
  build(1, 1, n);
  while (m--) {
    f = read(), x = read();
    if (f == 1) {
      y = read(), z = read();
      long long ans = query(x, y);
      if (ans <= 0)
        puts("0");
      else
        printf("%I64d\n", z / ans);
    } else {
      zz = read();
      int xx = b[x << 1], yy = b[(x << 1) - 1];
      if (deep[xx] < deep[yy]) swap(xx, yy);
      change(1, pos[xx], zz);
    }
  }
  return 0;
}
