#include <bits/stdc++.h>
using namespace std;
const long long inf = 1LL << 60;
const int N = 200100, L = 19;
int n, p[N][L], dep[N];
long long seg[N << 2];
int sz[N], timer = 1, q;
long long mrg(long long a, long long b) {
  if (a && b && (inf / a < b || inf / b < a)) return inf;
  return a * b;
}
struct tt {
  long long v, id, c;
  tt(long long x, long long y, long long z) { v = x, c = y, id = z; }
};
vector<tt> adj[N];
long long baseArray[N];
int chainNo, chainInd[N], chainHead[N], posInBase[N], idx[N];
void build(int nd, int L, int R) {
  if (L == R) {
    seg[nd] = baseArray[L];
    return;
  }
  int mid = (L + R) >> 1;
  build(nd << 1, L, mid);
  build(nd << 1 | 1, mid + 1, R);
  seg[nd] = mrg(seg[nd << 1], seg[nd << 1 | 1]);
}
void dfs(int u, int par = 0) {
  p[u][0] = par;
  dep[u] = 1 + dep[par];
  sz[u] = 1;
  for (auto v : adj[u])
    if (v.v != par) {
      dfs(v.v, u);
      idx[v.id] = v.v;
      sz[u] += sz[v.v];
    }
}
int jump(int u, int k) {
  for (int i = 0; i < L; i++)
    if (k & (1 << i)) u = p[u][i];
  return u;
}
int LCA(int u, int v) {
  if (u == v) return u;
  if (dep[u] < dep[v]) swap(u, v);
  int dif = dep[u] - dep[v];
  u = jump(u, dif);
  if (u == v) return u;
  for (int i = L - 1; i >= 0; i--)
    if (p[u][i] != p[v][i]) {
      u = p[u][i];
      v = p[v][i];
    }
  return p[u][0];
}
void HLD(int u, long long c = 0, int par = 0) {
  if (chainHead[chainNo] == -1) {
    chainHead[chainNo] = u;
  }
  chainInd[u] = chainNo;
  posInBase[u] = timer;
  baseArray[timer++] = c;
  int sc = -1;
  long long ncost;
  for (auto v : adj[u])
    if (v.v != par && (sc == -1 || sz[sc] < sz[v.v])) {
      sc = v.v;
      ncost = v.c;
    }
  if (sc != -1) {
    HLD(sc, ncost, u);
  }
  for (auto v : adj[u])
    if (v.v != par && sc != v.v) {
      chainNo++;
      HLD(v.v, v.c, u);
    }
}
void update(int nd, int L, int R, int idx, long long val) {
  if (L == R) {
    seg[nd] = val;
    return;
  }
  int mid = (L + R) >> 1;
  if (idx <= mid)
    update(nd << 1, L, mid, idx, val);
  else
    update(nd << 1 | 1, mid + 1, R, idx, val);
  seg[nd] = mrg(seg[nd << 1], seg[nd << 1 | 1]);
}
long long query(int nd, int L, int R, int from, int to) {
  if (from <= L && R <= to) return seg[nd];
  if (from > R || to < L) return 1;
  int mid = (L + R) >> 1;
  long long leftAns = query(nd << 1, L, mid, from, to);
  long long rightAns = query(nd << 1 | 1, mid + 1, R, from, to);
  return mrg(leftAns, rightAns);
}
long long query_up(int u, int v) {
  if (u == v) return 1;
  int uchain, vchain = chainInd[v];
  long long ANS = 1;
  while (1) {
    uchain = chainInd[u];
    if (uchain == vchain) {
      if (u == v) break;
      ANS = mrg(ANS, query(1, 1, timer, posInBase[v] + 1, posInBase[u]));
      break;
    }
    ANS = mrg(ANS,
              query(1, 1, timer, posInBase[chainHead[uchain]], posInBase[u]));
    u = chainHead[uchain];
    u = p[u][0];
  }
  return ANS;
}
void query(int u, int v, long long y) {
  int lca = LCA(u, v);
  long long ANS = query_up(u, lca);
  long long temp = query_up(v, lca);
  ANS = mrg(ANS, temp);
  printf("%lld\n", y / ANS);
}
void change(int i, long long val) {
  int u = idx[i];
  update(1, 1, timer, posInBase[u], val);
}
void init() {
  memset(chainHead, -1, sizeof chainHead);
  timer = 1;
  chainNo = 0;
}
void solve() {
  init();
  scanf("%d %d", &n, &q);
  for (int i = 1; i <= n - 1; i++) {
    long long x, y;
    long long c;
    scanf("%lld %lld %lld", &x, &y, &c);
    adj[x].push_back(tt(y, c, i));
    adj[y].push_back(tt(x, c, i));
  }
  dfs(1);
  HLD(1);
  timer--;
  build(1, 1, timer);
  for (int j = 1; j < L; j++)
    for (int i = 1; i <= n; i++) p[i][j] = p[p[i][j - 1]][j - 1];
  while (q--) {
    long long ty;
    scanf("%lld", &ty);
    if (ty == 1) {
      long long u, v;
      long long y;
      scanf("%lld %lld %lld", &v, &u, &y);
      query(u, v, y);
    } else {
      long long id;
      long long x;
      scanf("%lld %lld", &id, &x);
      change(id, x);
    }
  }
  for (int i = 1; i <= n; i++) adj[i].clear();
  return;
}
int main() {
  int t = 1;
  while (t--) solve();
  return 0;
}
