#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int MAXN = 220000;
int parent[MAXN], fa[MAXN], P[MAXN], deep[MAXN];
long long val[MAXN];
struct node {
  int v, id;
  long long w;
  node(int v, long long w, int id) : v(v), w(w), id(id) {}
};
vector<node> G[MAXN];
int find(int a) {
  if (a != parent[a]) parent[a] = find(parent[a]);
  return parent[a];
}
void unite(int a) { parent[a] = find(fa[a]); }
void dfs(int u, int p, int d) {
  fa[u] = p;
  deep[u] = d;
  for (int i = 0; i < G[u].size(); i++) {
    int v = G[u][i].v;
    long long w = G[u][i].w;
    if (v != p) {
      val[v] = w;
      P[G[u][i].id] = v;
      dfs(v, u, d + 1);
    }
  }
}
long long LCA(int u, int v, long long w) {
  while (u != v) {
    if (deep[u] < deep[v]) swap(u, v);
    w /= val[u];
    u = find(fa[u]);
    if (!w) return 0;
  }
  return w;
}
int main(int argc, char *argv[]) {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i <= n; i++) parent[i] = i;
  int u, v;
  long long w;
  for (int i = 1; i < n; i++) {
    scanf("%d%d%I64d", &u, &v, &w);
    G[u].push_back(node(v, w, i));
    G[v].push_back(node(u, w, i));
  }
  dfs(1, -1, 0);
  for (int i = 1; i <= n; i++)
    if (val[i] == 1) unite(i);
  int op, a, b;
  long long c;
  while (m--) {
    scanf("%d", &op);
    if (op == 1) {
      scanf("%d%d%I64d", &a, &b, &c);
      printf("%I64u\n", LCA(a, b, c));
    } else {
      scanf("%d%I64d", &a, &c);
      int v = P[a];
      val[v] = c;
      if (c == 1) unite(v);
    }
  }
  return 0;
}
