#include <bits/stdc++.h>
using namespace std;
const int N = 200000 + 10;
const int M = N + N;
const int P = 30;
struct graph {
  int head[N];
  int next[M];
  int node[M];
  long long dist[M];
  int tot;
  void init() {
    memset(head, -1, sizeof(head));
    ;
    tot = 0;
  }
  void add(int x, int y, long long z) {
    node[tot] = y;
    dist[tot] = z;
    next[tot] = head[x];
    head[x] = tot++;
  }
} g;
struct DCT {
  int father[N];
  void init(int n) {
    for (int i = 1; i <= n; ++i) father[i] = i;
  }
  int get(int x) {
    if (father[x] == x) return x;
    return father[x] = get(father[x]);
  }
  void mg(int x, int y) {
    y = get(y);
    father[y] = x;
  }
} dct;
int fa[N][P], deep[N], n, m;
long long value[N];
pair<int, int> edge[N];
int lift(int x, int delta) {
  if (!delta) return x;
  for (int i = 0; i < P; ++i) {
    if (delta & (1 << i)) x = fa[x][i];
  }
  return x;
}
int LCA(int x, int y) {
  if (deep[x] < deep[y]) swap(x, y);
  x = lift(x, deep[x] - deep[y]);
  if (x != y) {
    for (int i = P - 1; i >= 0; --i) {
      if (fa[x][i] != fa[y][i]) {
        x = fa[x][i];
        y = fa[y][i];
      }
    }
    x = fa[x][0];
    y = fa[y][0];
  }
  return x;
}
void LCA_init() {
  for (int i = 1; i < P; ++i)
    for (int j = 1; j <= n; ++j) fa[j][i] = fa[fa[j][i - 1]][i - 1];
}
void dfs(int x) {
  for (int i = g.head[x]; ~i; i = g.next[i]) {
    int y = g.node[i];
    if (y == fa[x][0]) continue;
    fa[y][0] = x;
    deep[y] = deep[x] + 1;
    value[y] = g.dist[i];
    if (g.dist[i] == 1) {
      dct.mg(x, y);
    }
    dfs(y);
  }
}
void query(int x, int lca, long long &v) {
  x = dct.get(x);
  lca = dct.get(lca);
  while (x != lca) {
    v /= value[x];
    if (v == 0) return;
    x = fa[x][0];
    x = dct.get(x);
  }
}
void update(int x, long long &y) {
  value[x] = y;
  if (y == 1) dct.mg(fa[x][0], x);
}
void solve() {
  int type, x, y;
  long long z;
  while (m--) {
    scanf("%d", &type);
    if (type == 1) {
      scanf("%d%d%I64d", &x, &y, &z);
      int lca = LCA(x, y);
      query(x, lca, z);
      query(y, lca, z);
      printf("%I64d\n", z);
    } else {
      scanf("%d%I64d", &x, &z);
      x = deep[edge[x].first] > deep[edge[x].second] ? edge[x].first
                                                     : edge[x].second;
      update(x, z);
    }
  }
}
int main() {
  scanf("%d%d", &n, &m);
  g.init();
  for (int i = 1; i < n; ++i) {
    int x, y;
    long long z;
    scanf("%d%d%I64d", &x, &y, &z);
    edge[i] = make_pair(x, y);
    g.add(x, y, z);
    g.add(y, x, z);
  }
  fa[1][0] = 0;
  deep[1] = 0;
  dct.init(n);
  dfs(1);
  LCA_init();
  solve();
}
