#include <bits/stdc++.h>
const int MAXN = 2e5 + 10;
const double eps = 1e-8;
const long double inf = 1e18;
using namespace std;
struct edge {
  int t, id;
  long long v;
  edge *next;
} e[MAXN << 1], *h[MAXN], *o = e;
void add(int x, int y, long long vul, int id) {
  o->t = y;
  o->v = vul;
  o->id = id;
  o->next = h[x];
  h[x] = o++;
}
long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  return x * f;
}
long long a[MAXN];
int son[MAXN], num[MAXN], dep[MAXN], fa[MAXN];
int pos[MAXN];
void dfs(int x, int pre, int deep) {
  num[x] = 1;
  dep[x] = deep + 1;
  fa[x] = pre;
  for (edge *j = h[x]; j; j = j->next) {
    if (j->t != pre) {
      a[j->t] = j->v;
      pos[j->id] = j->t;
      dfs(j->t, x, deep + 1);
      num[x] += num[j->t];
      if (son[x] == -1 || num[son[x]] < num[j->t]) son[x] = j->t;
    }
  }
}
int p[MAXN], fp[MAXN], cnt, tp[MAXN], n;
void dfs1(int x, int td) {
  p[x] = ++cnt;
  fp[p[x]] = x;
  tp[x] = td;
  if (son[x] != -1) dfs1(son[x], td);
  for (edge *j = h[x]; j; j = j->next) {
    if (j->t != fa[x] && j->t != son[x]) dfs1(j->t, j->t);
  }
}
bool tag[MAXN << 2];
long long sum[MAXN << 2];
bool check(long long x, long long y) {
  long double t1 = x;
  long double t2 = y;
  if (t1 * t2 > inf) {
    return 1;
  }
  return 0;
}
void up(int rt) {
  if (tag[rt << 1] || tag[rt << 1 | 1]) {
    tag[rt] = 1;
    return;
  }
  long double t1 = sum[rt << 1];
  long double t2 = sum[rt << 1 | 1];
  if (t1 * t2 > inf) {
    tag[rt] = 1;
    return;
  }
  tag[rt] = 0;
  if (!sum[rt << 1] || !sum[rt << 1 | 1])
    sum[rt] = max(sum[rt << 1], sum[rt << 1 | 1]);
  else
    sum[rt] = sum[rt << 1] * sum[rt << 1 | 1];
}
void built(int rt, int l, int r) {
  if (l == r) {
    sum[rt] = a[fp[l]];
    return;
  }
  int mid = (l + r) >> 1;
  built(rt << 1, l, mid);
  built(rt << 1 | 1, mid + 1, r);
  up(rt);
}
void update(int rt, int l, int r, int t, long long key) {
  if (l == r) {
    sum[rt] = key;
    return;
  }
  int mid = (l + r) >> 1;
  if (t <= mid)
    update(rt << 1, l, mid, t, key);
  else
    update(rt << 1 | 1, mid + 1, r, t, key);
  up(rt);
}
bool flag;
long long ans;
void querty(int rt, int l, int r, int ql, int qr) {
  if (flag) return;
  if (ql <= l && r <= qr) {
    if (tag[rt]) {
      flag = 1;
      return;
    } else {
      flag = check(ans, sum[rt]);
      if (!flag) ans *= sum[rt];
      return;
    }
  }
  int mid = (l + r) >> 1;
  if (ql <= mid) querty(rt << 1, l, mid, ql, qr);
  if (qr > mid) querty(rt << 1 | 1, mid + 1, r, ql, qr);
}
int Lca(int u, int v) {
  int uu = tp[u];
  int vv = tp[v];
  while (uu != vv) {
    if (dep[uu] < dep[vv]) {
      swap(uu, vv);
      swap(u, v);
    }
    u = fa[uu];
    uu = tp[u];
  }
  if (dep[u] > dep[v]) swap(u, v);
  return u;
}
stack<pair<int, int> > s;
long long slove(int u, int v, int long long t) {
  while (!s.empty()) s.pop();
  int lca = Lca(u, v);
  int uu = tp[u];
  int vv = tp[lca];
  ans = 1;
  flag = 0;
  while (uu != vv) {
    querty(1, 1, n, p[uu], p[u]);
    if (flag) return 0;
    u = fa[uu];
    uu = tp[u];
  }
  if (u != lca) {
    querty(1, 1, n, p[son[lca]], p[u]);
    if (flag) return 0;
  }
  uu = tp[v];
  vv = tp[lca];
  while (uu != vv) {
    s.push((pair<int, int>){p[uu], p[v]});
    v = fa[uu];
    uu = tp[v];
  }
  if (v != lca) {
    s.push((pair<int, int>){p[son[lca]], p[v]});
  }
  while (!s.empty()) {
    pair<int, int> t = s.top();
    s.pop();
    querty(1, 1, n, t.first, t.second);
    if (flag) return 0;
  }
  return t / ans;
}
int main() {
  n = read();
  int m = read();
  for (int i = 1; i <= n; i++) son[i] = -1;
  int u, v, op;
  long long t;
  for (int i = 1; i <= n - 1; i++)
    u = read(), v = read(), t = read(), add(u, v, t, i), add(v, u, t, i);
  dfs(1, 0, 0);
  dfs1(1, 1);
  built(1, 1, n);
  while (m--) {
    op = read();
    if (op == 1)
      u = read(), v = read(), t = read(), printf("%lld\n", slove(u, v, t));
    else
      u = read(), t = read(), update(1, 1, n, p[pos[u]], t);
  }
  return 0;
}
