#include <bits/stdc++.h>
using namespace std;
const int MXN = 200010, MXM = 200010;
struct node {
  int v, pos;
  node(int v, int pos) : v(v), pos(pos) {}
};
int n, m, w[MXN], L[MXN], R[MXN], p[MXN], Mytime;
long long c[MXM];
vector<node> E[MXN];
int getfather(int x) {
  if (c[w[x]] != 1) return x;
  return p[x] = getfather(p[x]);
}
void DFS(int u) {
  L[u] = ++Mytime;
  for (int i = 0; i < E[u].size(); i++)
    if (E[u][i].v != p[u]) {
      p[E[u][i].v] = u;
      w[E[u][i].v] = E[u][i].pos;
      DFS(E[u][i].v);
    }
  R[u] = Mytime;
}
void Do(int u, int v, long long &z) {
  if (!u || !z) return;
  if (L[u] <= L[v] && R[u] >= R[v]) return;
  z /= c[w[u]];
  p[u] = getfather(p[u]);
  Do(p[u], v, z);
}
inline void solve() {
  int u, v, op;
  long long z;
  scanf("%d%d", &n, &m);
  for (int i = 1; i < n; i++) {
    scanf("%d%d%I64d", &u, &v, &z);
    E[u].push_back(node(v, i));
    E[v].push_back(node(u, i));
    c[i] = z;
  }
  DFS(1);
  for (int i = 1; i <= m; i++) {
    scanf("%d", &op);
    if (op == 1) {
      scanf("%d%d%I64d", &u, &v, &z);
      Do(u, v, z);
      Do(v, u, z);
      printf("%I64d\n", z);
    } else {
      scanf("%d%I64d", &u, &z);
      c[u] = z;
    }
  }
}
int main() {
  solve();
  return 0;
}
