#include <bits/stdc++.h>
using namespace std;
int n, q;
vector<pair<int, long long> > g[200100];
vector<int> num[200100];
int dir[200100];
int contchain = 1, chainsize[200100], chain[200100];
int parent[200100], chainpos[200100], chainhead[200100];
int subsize[200100], lef[4 * 200100], rig[4 * 200100];
long long st[4 * 200100];
int root[200100], cont = 1;
long long v[200100];
int p[200100][21];
int h[200100];
long long mul(long long a, long long b) {
  long double aa = a;
  long double bb = b;
  aa *= bb;
  if (aa > 1e18)
    return 0x3F3F3F3F3F3F3F3FLL;
  else
    return a * b;
}
int dfs(int x, int pai) {
  int sum = 0, y;
  p[x][0] = pai;
  for (int i = 1; i < 21; ++i) p[x][i] = p[p[x][i - 1]][i - 1];
  for (int i = 0; i < (int)g[x].size(); ++i) {
    y = g[x][i].first;
    if (y == pai) continue;
    v[y] = g[x][i].second;
    dir[num[x][i]] = y;
    h[y] = h[x] + 1;
    sum += dfs(y, x);
  }
  subsize[x] = 1 + sum;
  return subsize[x];
}
void hld(int x, int pai) {
  if (!chainhead[contchain]) chainhead[contchain] = x;
  chainpos[x] = chainsize[contchain]++;
  chain[x] = contchain;
  parent[x] = pai;
  int maior = -1, y;
  for (int i = 0; i < (int)g[x].size(); ++i) {
    y = g[x][i].first;
    if (y == pai) continue;
    if (maior == -1 || subsize[y] > subsize[maior]) maior = y;
  }
  if (maior != -1) hld(maior, x);
  for (int i = 0; i < (int)g[x].size(); ++i) {
    y = g[x][i].first;
    if (y == maior || y == pai) continue;
    contchain++;
    hld(y, x);
  }
}
int atchain;
void build(int p, int l, int r) {
  if (l == r) {
    st[p] = 1;
    return;
  }
  lef[p] = cont++;
  rig[p] = cont++;
  build(lef[p], l, (l + r) / 2);
  build(rig[p], (l + r) / 2 + 1, r);
  st[p] = 1;
}
void update(int p, int l, int r, int x, long long valor) {
  if (x < l || x > r) return;
  if (x == l && x == r) {
    st[p] = valor;
    return;
  }
  update(lef[p], l, (l + r) / 2, x, valor);
  update(rig[p], (l + r) / 2 + 1, r, x, valor);
  st[p] = mul(st[lef[p]], st[rig[p]]);
}
long long query(int p, int l, int r, int i, int j) {
  if (l > j || r < i) return 1;
  if (l >= i && r <= j) return st[p];
  long long p1 = query(lef[p], l, (l + r) / 2, i, j);
  long long p2 = query(rig[p], (l + r) / 2 + 1, r, i, j);
  return mul(p1, p2);
}
void updateup(int x) {
  int chainx = chain[x];
  update(root[chainx], 0, chainsize[chainx] - 1, chainpos[x], x);
}
long long queryup(int x, int y) {
  long long ans = 1;
  int chainx;
  while (1) {
    chainx = chain[x];
    if (chainx == chain[y]) break;
    ans =
        mul(ans, query(root[chainx], 0, chainsize[chainx] - 1, 0, chainpos[x]));
    x = parent[chainhead[chainx]];
  }
  if (x != y)
    ans = mul(ans, query(root[chainx], 0, chainsize[chainx] - 1,
                         chainpos[y] + 1, chainpos[x]));
  return ans;
}
int lca(int x, int y) {
  if (h[x] < h[y]) swap(x, y);
  for (int i = 20; i >= 0; --i)
    if (h[p[x][i]] >= h[y]) x = p[x][i];
  if (x == y) return x;
  for (int i = 20; i >= 0; --i)
    if (p[x][i] != p[y][i]) x = p[x][i], y = p[y][i];
  return p[x][0];
}
int main() {
  int x, y;
  long long valor;
  scanf("%d %d", &n, &q);
  for (int i = 1; i <= n; ++i)
    for (int j = 0; j < 21; ++j) p[i][j] = 1;
  for (int i = 0; i < n - 1; ++i) {
    scanf("%d %d %lld", &x, &y, &valor);
    g[x].push_back(make_pair(y, valor));
    g[y].push_back(make_pair(x, valor));
    num[x].push_back(i + 1);
    num[y].push_back(i + 1);
  }
  dfs(1, 1);
  hld(1, 1);
  v[1] = 1;
  for (int i = 1; i <= contchain; ++i) {
    atchain = i;
    root[i] = cont++;
    build(root[i], 0, chainsize[i] - 1);
  }
  for (int i = 1; i <= n; ++i) {
    update(root[chain[i]], 0, chainsize[chain[i]] - 1, chainpos[i], v[i]);
  }
  for (int i = 0; i < q; ++i) {
    int op;
    scanf("%d", &op);
    if (op == 1) {
      scanf("%d %d %lld", &x, &y, &valor);
      int l = lca(x, y);
      long long xx = mul(queryup(x, l), queryup(y, l));
      if (xx == 0x3F3F3F3F3F3F3F3FLL)
        valor = 0;
      else
        valor /= xx;
      printf("%lld\n", valor);
    } else {
      scanf("%d %lld", &x, &valor);
      x = dir[x];
      update(root[chain[x]], 0, chainsize[chain[x]] - 1, chainpos[x], valor);
    }
  }
  return 0;
}
