#include <bits/stdc++.h>
using namespace std;
struct node {
  int to;
  long long v;
};
int fa[200005];
long long dis[200005];
int dp[200005][20], dep[200005], U[200005], V[200005];
vector<node> edge[200005];
int get(int x) {
  if (fa[x] == x)
    return x;
  else
    return fa[x] = get(fa[x]);
}
void dfs(int x, int f, int d) {
  int j, k;
  dep[x] = d;
  dp[x][0] = f;
  for (j = 1; j <= 18; j++) dp[x][j] = dp[dp[x][j - 1]][j - 1];
  for (j = 0; j < edge[x].size(); j++) {
    int to = edge[x][j].to;
    if (to == f) continue;
    dis[to] = edge[x][j].v;
    dfs(to, x, d + 1);
  }
}
int up(int x, int d) {
  for (int j = 0; j <= 18; j++) {
    if (d & (1 << j)) x = dp[x][j];
  }
  return x;
}
int get_lca(int x, int y) {
  if (dep[x] < dep[y]) swap(x, y);
  x = up(x, dep[x] - dep[y]);
  if (x == y) return x;
  for (int j = 18; j >= 0; j--) {
    if (dp[x][j] != dp[y][j]) x = dp[x][j], y = dp[y][j];
  }
  return dp[x][0];
}
long long solve(int x, int y, long long z) {
  int lca = get_lca(x, y);
  x = get(x);
  y = get(y);
  while (dep[x] > dep[lca]) {
    z /= dis[x];
    x = dp[x][0];
    x = get(x);
    if (z == 0) return 0;
  }
  while (dep[y] > dep[lca]) {
    z /= dis[y];
    y = dp[y][0];
    y = get(y);
    if (z == 0) return 0;
  }
  return z;
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int j, k;
  for (j = 1; j <= n; j++) {
    fa[j] = j;
    edge[j].clear();
  }
  for (j = 1; j < n; j++) {
    int a, b;
    long long c;
    scanf("%d%d", &a, &b);
    cin >> c;
    edge[a].push_back((node){b, c});
    edge[b].push_back((node){a, c});
    U[j] = a, V[j] = b;
  }
  dfs(1, 0, 1);
  for (j = 1; j < n; j++) {
    int u = U[j], v = V[j];
    if (dep[u] < dep[v]) swap(u, v);
    if (dis[u] == 1) fa[get(u)] = get(v);
  }
  for (j = 1; j <= m; j++) {
    int op;
    scanf("%d", &op);
    if (op == 1) {
      int a, b;
      long long c;
      scanf("%d%d", &a, &b);
      cin >> c;
      cout << solve(a, b, c) << endl;
    } else {
      int a;
      long long b;
      scanf("%d", &a);
      cin >> b;
      int u = U[a], v = V[a];
      if (dep[u] < dep[v]) swap(u, v);
      dis[u] = b;
      if (b == 1) fa[get(u)] = get(v);
    }
  }
  return 0;
}
