#include <bits/stdc++.h>
using namespace std;
long long int n, m, x, y, w, c, par[200005][21], h[200005], maxlog, nxt[200005],
    val[200005], ind[200005];
vector<long long int> g[200005], weight[200005], edge[200005];
void dfs(int v, int p) {
  par[v][0] = p;
  if (p != -1) h[v] = h[p] + 1;
  for (int i = 1; i < maxlog; i++) {
    if (par[v][i - 1] != -1) par[v][i] = par[par[v][i - 1]][i - 1];
  }
  for (auto u : g[v])
    if (p - u) dfs(u, v);
}
int lca(int v, int u) {
  if (h[v] < h[u]) swap(v, u);
  for (int i = maxlog - 1; i >= 0; i--) {
    if (par[v][i] != -1 && h[par[v][i]] >= h[u]) {
      v = par[v][i];
    }
  }
  if (v == u) return u;
  for (int i = maxlog - 1; i >= 0; i--) {
    if (par[v][i] - par[u][i]) v = par[v][i], u = par[u][i];
  }
  return par[v][0];
}
void dfs1(int v, int p) {
  for (int i = 0; i < g[v].size(); i++) {
    int u = g[v][i];
    if (u != p) {
      ind[edge[v][i]] = u;
      val[u] = weight[v][i];
      nxt[u] = v;
      dfs1(u, v);
    }
  }
}
int root(int v) {
  if (v == 1) return 1;
  return val[v] > 1 || val[nxt[v]] > 1 ? nxt[v] : (nxt[v] = root(nxt[v]));
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m;
  maxlog = log2(n) + 1;
  memset(par, -1, sizeof par);
  for (int i = 1; i < n; i++) {
    cin >> x >> y >> w;
    g[x].push_back(y);
    g[y].push_back(x);
    weight[x].push_back(w);
    weight[y].push_back(w);
    edge[x].push_back(i);
    edge[y].push_back(i);
  }
  h[1] = 0;
  val[1] = 1;
  dfs(1, -1);
  dfs1(1, -1);
  long long int l;
  vector<long long int> s;
  while (m--) {
    cin >> c;
    if (c == 1) {
      s.clear();
      cin >> x >> y >> w;
      l = lca(x, y);
      while (h[x] > h[l]) {
        if (val[x] != 1) s.push_back(val[x]);
        x = root(x);
        if (s.size() > 70) break;
      }
      while (h[y] > h[l]) {
        if (s.size() > 70) break;
        if (val[y] != 1) s.push_back(val[y]);
        y = root(y);
      }
      while (w > 0 && !s.empty()) {
        w = w / s.back();
        s.pop_back();
      }
      cout << w << endl;
    } else {
      cin >> x >> w;
      val[ind[x]] = w;
    }
  }
  return 0;
}
