#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long INFLL = 0x3f3f3f3f3f3f3f3fLL;
inline long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
const int maxn = 2e5 + 10;
int _pow[25];
int tot, head[maxn], ver[2 * maxn], R[2 * maxn], first[maxn], dis[maxn],
    fa[maxn], deep[maxn], ff[maxn];
long long col[maxn];
int dp[2 * maxn][25];
bool vis[maxn];
struct edge {
  int u, v, next;
  long long w;
} e[2 * maxn];
void add(int u, int v, long long w, int &k) {
  e[k].u = u;
  e[k].v = v;
  e[k].w = w;
  e[k].next = head[u];
  head[u] = k++;
  swap(u, v);
  e[k].u = u;
  e[k].v = v;
  e[k].w = w;
  e[k].next = head[u];
  head[u] = k++;
}
int find(int x) { return fa[x] == x ? x : fa[x] = find(fa[x]); }
void dfs(int u, int f, int dep) {
  vis[u] = true;
  ver[++tot] = u;
  first[u] = tot;
  R[tot] = dep;
  deep[u] = dep;
  ff[u] = f;
  for (int i = head[u]; i != -1; i = e[i].next) {
    if (vis[e[i].v]) continue;
    int v = e[i].v;
    long long w = e[i].w;
    dis[v] = dis[u] + w;
    dfs(v, u, dep + 1);
    col[v] = w;
    ver[++tot] = u;
    R[tot] = dep;
    if (w == 1) {
      int fx = find(v), fy = find(u);
      fa[fx] = fy;
    }
  }
}
void ST(int len) {
  int k = (int)(log((double)len) / log(2.0));
  for (int i = 1; i <= len; i++) dp[i][0] = i;
  for (int j = 1; j <= k; j++) {
    for (int i = 1; i + _pow[j] - 1 <= len; i++) {
      int a = dp[i][j - 1], b = dp[i + _pow[j - 1]][j - 1];
      if (R[a] < R[b])
        dp[i][j] = a;
      else
        dp[i][j] = b;
    }
  }
}
int RMQ(int x, int y) {
  int k = (int)(log((double)(y - x + 1)) / log(2.0));
  int a = dp[x][k], b = dp[y - _pow[k] + 1][k];
  if (R[a] < R[b])
    return a;
  else
    return b;
}
int LCA(int u, int v) {
  int x = first[u], y = first[v];
  if (x > y) swap(x, y);
  int res = RMQ(x, y);
  return ver[res];
}
long long calc(int u, int v, int Lca, long long val) {
  int ccnt = 0;
  while (deep[u] > deep[Lca]) {
    int anc = find(u);
    if (deep[anc] <= deep[Lca]) break;
    val /= col[anc];
    ccnt++;
    if (ccnt > 64) return 0;
    if (val == 0) return 0;
    u = ff[anc];
  }
  while (deep[v] > deep[Lca]) {
    int anc = find(v);
    if (deep[anc] <= deep[Lca]) break;
    val /= col[anc];
    ccnt++;
    if (ccnt > 64) return 0;
    if (val == 0) return 0;
    v = ff[anc];
  }
  return val;
}
void change(int no, long long val) {
  int x = e[no].u, y = e[no].v;
  if (ff[y] == x) swap(x, y);
  col[x] = val;
  if (val == 1) {
    int fx = find(x), fy = find(y);
    fa[fx] = fy;
  }
}
int main() {
  for (int i = 0; i < 25; i++) _pow[i] = (1 << i);
  memset(head, -1, sizeof(head));
  memset(vis, 0, sizeof(vis));
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) fa[i] = i;
  int num = 0;
  for (int i = 1; i < n; i++) {
    int u, v;
    long long w;
    scanf("%d%d%I64d", &u, &v, &w);
    add(u, v, w, num);
  }
  dfs(1, 0, 0);
  ST(num);
  while (m--) {
    int op = read();
    int u, v, p;
    long long w;
    if (op == 1) {
      scanf("%d%d%I64d", &u, &v, &w);
      int lca = LCA(u, v);
      printf("%I64d\n", calc(u, v, lca, w));
    } else if (op == 2) {
      scanf("%d%I64d", &p, &w);
      change((p - 1) * 2, w);
    }
  }
  return 0;
}
