#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void checkMin(T &a, T b) {
  if (b < a) a = b;
}
template <typename T>
inline void checkMax(T &a, T b) {
  if (a < b) a = b;
}
const int MAX_N = 200100;
const int MAX_M = MAX_N * 2;
struct EdgeNode {
  int to;
  long long weight;
  int next;
} ed[MAX_M];
int head[MAX_N], en;
int go[MAX_N];
int dep[MAX_N];
int par[18][MAX_N];
void dfs(int u, int d) {
  dep[u] = d;
  for (int p = head[u]; p != -1; p = ed[p].next) {
    if (p == go[u]) continue;
    int v = ed[p].to;
    go[v] = p ^ 1;
    par[0][v] = u;
    dfs(v, d + 1);
  }
}
int lca(int u, int v) {
  if (dep[u] < dep[v]) swap(u, v);
  for (int k = 17; k >= 0; --k) {
    int p = par[k][u];
    if (dep[p] >= dep[v]) u = p;
  }
  if (u == v) return u;
  for (int k = 17; k >= 0; --k) {
    int x = par[k][u], y = par[k][v];
    if (x != y) u = x, v = y;
  }
  return par[0][u];
}
long long y;
int d;
void work(int u) {
  if (go[u] == 0 || y <= 0) return;
  int v = ed[go[u]].to;
  if (dep[v] < d) return;
  y /= ed[go[u]].weight;
  work(v);
  if (ed[go[u]].weight == 1) {
    go[u] = go[v];
  }
}
int main() {
  std::ios_base::sync_with_stdio(false);
  int n, m, u, v;
  long long w;
  cin >> n >> m;
  en = 0;
  fill(head, head + MAX_N, -1);
  ;
  en = 2;
  for (int i = 0; i < int(n - 1); ++i) {
    cin >> u >> v >> w;
    {
      ed[en].to = v;
      ed[en].weight = w;
      ed[en].next = head[u];
      head[u] = en++;
    };
    {
      ed[en].to = u;
      ed[en].weight = w;
      ed[en].next = head[v];
      head[v] = en++;
    };
  }
  par[0][1] = 1;
  dfs(1, 1);
  for (int k = 1; k < 18; ++k) {
    for (int u = 1; u <= n; ++u) {
      par[k][u] = par[k - 1][par[k - 1][u]];
    }
  }
  int op, a, b, p;
  long long c;
  for (int i = 0; i < int(m); ++i) {
    cin >> op;
    if (op == 1) {
      cin >> a >> b >> y;
      int l = lca(a, b);
      d = dep[l];
      work(a);
      work(b);
      cout << y << "\n";
    } else {
      cin >> p >> c;
      ed[2 * p].weight = ed[2 * p + 1].weight = c;
    }
  }
  return 0;
}
