#include <bits/stdc++.h>
using namespace std;
int n, m;
int head[200100], cnt;
struct Line {
  int u, v;
  long long val;
} l[200100];
struct node {
  int from, to, next;
  long long val;
} edge[200100 << 1];
void init() {
  memset(head, -1, sizeof(head));
  cnt = 1;
}
int ancestor[200100];
int find(int x) {
  if (x == ancestor[x]) return x;
  return ancestor[x] = find(ancestor[x]);
}
void edgeadd(int from, int to, long long val) {
  edge[cnt].from = from, edge[cnt].to = to, edge[cnt].val = val;
  edge[cnt].next = head[from];
  head[from] = cnt++;
}
int deep[200100], fa[200100][21];
long long col[200100];
void dfs(int now, int ff) {
  deep[now] = deep[ff] + 1;
  fa[now][0] = ff;
  for (int i = head[now]; i != -1; i = edge[i].next) {
    int to = edge[i].to;
    if (to == ff) continue;
    dfs(to, now);
    col[to] = edge[i].val;
    if (edge[i].val == 1) {
      int fx = find(to), fy = find(now);
      ancestor[fx] = fy;
    }
  }
}
int lca(int x, int y) {
  if (deep[x] < deep[y]) swap(x, y);
  for (int i = 20; i >= 0; i--)
    if (deep[fa[x][i]] >= deep[y]) x = fa[x][i];
  if (x == y) return x;
  for (int i = 20; i >= 0; i--)
    if (fa[x][i] != fa[y][i]) x = fa[x][i], y = fa[y][i];
  return fa[x][0];
}
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 = fa[anc][0];
  }
  while (deep[v] > deep[Lca]) {
    int anc = find(v);
    if (deep[anc] <= deep[Lca]) break;
    val /= col[anc];
    if (ccnt > 64) return 0;
    if (val == 0) return 0;
    v = fa[anc][0];
  }
  return val;
}
void change(int no, long long val) {
  int x = l[no].u, y = l[no].v;
  if (fa[y][0] == x) swap(x, y);
  col[x] = val;
  if (val == 1) {
    int fx = find(x), fy = find(y);
    ancestor[fx] = fy;
  }
}
int main() {
  init();
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) ancestor[i] = i;
  for (int i = 1; i < n; i++) {
    scanf("%d%d%I64d", &l[i].u, &l[i].v, &l[i].val);
    edgeadd(l[i].u, l[i].v, l[i].val);
    edgeadd(l[i].v, l[i].u, l[i].val);
  }
  dfs(1, 0);
  for (int i = 1; i <= 20; i++)
    for (int j = 1; j <= n; j++) fa[j][i] = fa[fa[j][i - 1]][i - 1];
  for (int i = 1; i <= m; i++) {
    int opt;
    scanf("%d", &opt);
    if (opt == 1) {
      int u, v;
      long long val;
      scanf("%d%d%I64d", &u, &v, &val);
      int tmp = lca(u, v);
      printf("%I64d\n", calc(u, v, tmp, val));
    } else {
      int x;
      long long val;
      scanf("%d%I64d", &x, &val);
      change(x, val);
    }
  }
}
