#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const int N = 200510;
struct edge {
  int to, nxt, id;
  edge() {}
  edge(int _to, int _nxt) : to(_to), nxt(_nxt) {}
} E[N << 1];
struct seg {
  int l, mid, r;
  long long v;
} T[N << 2];
int head[N], tot;
int idx[N], son[N], fa[N], top[N], dep[N], sz[N], ts;
int U[N], V[N];
long long W[N];
long long MAX = 1e18 + 256LL;
double wid;
void init() {
  memset(head, -1, sizeof(head));
  tot = 0;
  ts = 0;
}
inline void add(int s, int t) {
  E[tot] = edge(t, head[s]);
  head[s] = tot++;
}
void dfs1(int u, int f, int d) {
  fa[u] = f;
  dep[u] = d;
  sz[u] = 1;
  son[u] = 0;
  for (int i = head[u]; ~i; i = E[i].nxt) {
    int v = E[i].to;
    if (v != f) {
      dfs1(v, u, d + 1);
      sz[u] += sz[v];
      if (!son[u] || sz[son[u]] < sz[v]) son[u] = v;
    }
  }
}
void dfs2(int u, int tp) {
  top[u] = tp;
  idx[u] = ++ts;
  if (son[u]) dfs2(son[u], tp);
  for (int i = head[u]; ~i; i = E[i].nxt) {
    int v = E[i].to;
    if (v != son[u] && v != fa[u]) dfs2(v, v);
  }
}
void pushup(int k) {
  if (log10(1.0 * T[(k << 1)].v) + log10(1.0 * T[((k << 1) + 1)].v) >= wid)
    T[k].v = MAX;
  else
    T[k].v = T[(k << 1)].v * T[((k << 1) + 1)].v;
}
void build(int k, int l, int r) {
  T[k].l = l;
  T[k].r = r;
  T[k].mid = ((l + r) >> 1);
  T[k].v = 1;
  if (l == r) return;
  build((k << 1), l, T[k].mid);
  build(((k << 1) + 1), T[k].mid + 1, r);
}
void update(int k, int pos, long long v) {
  if (T[k].l == T[k].r)
    T[k].v = v;
  else {
    if (pos <= T[k].mid)
      update((k << 1), pos, v);
    else
      update(((k << 1) + 1), pos, v);
    pushup(k);
  }
}
long long query(int k, int l, int r) {
  if (l <= T[k].l && T[k].r <= r)
    return T[k].v;
  else {
    if (r <= T[k].mid)
      return query((k << 1), l, r);
    else if (l > T[k].mid)
      return query(((k << 1) + 1), l, r);
    else {
      long long ls = query((k << 1), l, T[k].mid);
      long long rs = query(((k << 1) + 1), T[k].mid + 1, r);
      if (log10(ls) + log10(rs) >= wid)
        return MAX;
      else
        return ls * rs;
    }
  }
}
namespace SG {
long long Query(int u, int v, long long x) {
  int tu = top[u], tv = top[v];
  while (tu != tv) {
    if (dep[tu] < dep[tv]) {
      swap(tu, tv);
      swap(u, v);
    }
    x /= query(1, idx[tu], idx[u]);
    if (x == 0) return x;
    u = fa[tu];
    tu = top[u];
  }
  if (u == v) return x;
  if (dep[u] > dep[v]) swap(u, v);
  x /= query(1, idx[son[u]], idx[v]);
  return x;
}
void solve(int i, long long x) {
  int u = U[i], v = V[i];
  if (dep[v] > dep[u]) swap(v, u);
  update(1, idx[u], x);
}
}  // namespace SG
int main(void) {
  wid = 1.0 * log10(MAX);
  int n, m, i;
  while (~scanf("%d%d", &n, &m)) {
    init();
    for (i = 1; i < n; ++i) {
      scanf("%d%d%I64d", &U[i], &V[i], &W[i]);
      add(U[i], V[i]);
      add(V[i], U[i]);
    }
    dfs1(1, -1, 1);
    dfs2(1, 1);
    build(1, 1, n);
    for (i = 1; i < n; ++i) {
      if (dep[U[i]] < dep[V[i]]) swap(U[i], V[i]);
      update(1, idx[U[i]], W[i]);
    }
    while (m--) {
      int ops;
      scanf("%d", &ops);
      if (ops == 1) {
        int u, v;
        long long x;
        scanf("%d%d%I64d", &u, &v, &x);
        printf("%I64d\n", SG::Query(u, v, x));
      } else {
        int i;
        long long w;
        scanf("%d%I64d", &i, &w);
        SG::solve(i, w);
      }
    }
  }
  return 0;
}
