#include <bits/stdc++.h>
using namespace std;
const long long int INF = 1000000000000000001;
const int MAXN = 200010;
int n, mm;
int fat[MAXN], siz[MAXN], son[MAXN], deg[MAXN], top[MAXN], pos[MAXN], fp[MAXN],
    no;
long long int val[MAXN];
long long int t[MAXN * 4];
vector<pair<int, long long int> > G[MAXN];
struct EDGE {
  int from, to;
  long long int cost;
} e[MAXN];
void dfs1(int u, int fa, int depth) {
  deg[u] = depth;
  fat[u] = fa;
  siz[u] = 1;
  son[u] = -1;
  int ee = G[u].size();
  for (int i = 0; i < ee; i++) {
    int v = G[u][i].first;
    if (v == fa) continue;
    val[v] = G[u][i].second;
    dfs1(v, u, depth + 1);
    if (son[u] == -1 || siz[son[u]] < siz[v]) son[u] = v;
    siz[u] += siz[v];
  }
  return;
}
void dfs2(int u, int tops) {
  pos[u] = no++;
  fp[pos[u]] = u;
  top[u] = tops;
  if (son[u] != -1) dfs2(son[u], tops);
  int ee = G[u].size();
  for (int i = 0; i < ee; i++) {
    int v = G[u][i].first;
    if (v == fat[u] || v == son[u]) continue;
    dfs2(v, v);
  }
  return;
}
void PushUp(int x) {
  long long int sa = t[x * 2], sb = t[x * 2 + 1];
  if (sa == INF || sb == INF) {
    t[x] = INF;
    return;
  }
  long long int tmp = INF / sa;
  if (tmp < sb)
    t[x] = INF;
  else
    t[x] = sa * sb;
}
void Build(int l, int r, int x) {
  if (l == r) {
    t[x] = val[fp[l]];
    return;
  }
  int m = (l + r) / 2;
  Build(l, m, x * 2);
  Build(m + 1, r, x * 2 + 1);
  PushUp(x);
}
void Modify(int idx, long long int v, int l, int r, int x) {
  if (l == r) {
    t[x] = v;
    return;
  }
  int m = (l + r) / 2;
  if (idx <= m)
    Modify(idx, v, l, m, x * 2);
  else
    Modify(idx, v, m + 1, r, x * 2 + 1);
  PushUp(x);
}
long long int Query(int L, int R, int l, int r, int x) {
  if (L == l && R == r) return t[x];
  int m = (r + l) / 2;
  if (R <= m)
    return Query(L, R, l, m, x * 2);
  else if (L > m)
    return Query(L, R, m + 1, r, x * 2 + 1);
  else {
    long long int sa = Query(L, m, l, m, x * 2);
    long long int sb = Query(m + 1, R, m + 1, r, x * 2 + 1);
    long long int tmp = INF / sa;
    if (tmp < sb)
      return INF;
    else
      return sa * sb;
  }
}
long long int get(int x, int y) {
  long long int ret = 1;
  int f1 = top[x], f2 = top[y];
  while (f1 != f2) {
    if (deg[f1] < deg[f2]) {
      swap(f1, f2);
      swap(x, y);
    }
    long long int tmp = Query(pos[f1], pos[x], 1, n, 1);
    long long int an = INF / tmp;
    if (ret > an) return INF;
    ret *= tmp;
    ret = min(INF, ret);
    if (ret == INF) return ret;
    x = fat[f1];
    f1 = top[x];
  }
  if (deg[x] < deg[y]) {
    swap(x, y);
  }
  if (x == y) return ret;
  long long int temp = Query(pos[son[y]], pos[x], 1, n, 1);
  long long int an = INF / temp;
  if (ret > an) return INF;
  ret *= temp;
  return ret;
}
int main() {
  while (scanf("%d%d", &n, &mm) != EOF) {
    int ta, tb;
    for (int i = 0; i < MAXN; i++) G[i].clear();
    for (int i = 1; i < n; i++) {
      scanf("%d%d%I64d", &e[i].from, &e[i].to, &e[i].cost);
      G[e[i].from].push_back(make_pair(e[i].to, e[i].cost));
      G[e[i].to].push_back(make_pair(e[i].from, e[i].cost));
    }
    dfs1(1, 1, 1);
    no = 1;
    val[1] = 1;
    dfs2(1, 1);
    for (int i = 1; i < n; i++) {
      if (deg[e[i].from] > deg[e[i].to]) swap(e[i].from, e[i].to);
    }
    Build(1, n, 1);
    int op;
    long long int tc;
    while (mm--) {
      scanf("%d", &op);
      if (op == 1) {
        scanf("%d%d%I64d", &ta, &tb, &tc);
        long long int ans = get(ta, tb);
        printf("%I64d\n", tc / ans);
      } else {
        scanf("%d%I64d", &ta, &tc);
        ta = e[ta].to;
        Modify(pos[ta], tc, 1, n, 1);
      }
    }
  }
  return 0;
}
