#include <bits/stdc++.h>
using namespace std;
using llint = long long;
using par = pair<int, int>;
const int MAXN = 200100;
llint w[MAXN];
vector<par> edges[MAXN];
int p[MAXN], in[MAXN], out[MAXN], idx[MAXN], id;
void dfs(int u) {
  in[u] = ++id;
  for (const auto& edge : edges[u]) {
    if (edge.first == p[u]) continue;
    p[edge.first] = u;
    idx[edge.first] = edge.second;
    dfs(edge.first);
  }
  out[u] = id;
}
int next(int u) { return w[idx[u]] == 1 ? p[u] = next(p[u]) : u; }
void toLCA(int u, int v, llint& c) {
  if (!u || !c) return;
  if (in[u] <= in[v] && out[u] >= out[v]) return;
  c /= w[idx[u]];
  toLCA(p[u] = next(p[u]), v, c);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  llint c;
  int n, m, u, v;
  cin >> n >> m;
  for (int i = 1; i < n; ++i) {
    cin >> u >> v >> w[i];
    edges[u].emplace_back(v, i);
    edges[v].emplace_back(u, i);
  }
  dfs(1);
  while (m--) {
    cin >> u;
    if (u == 1) {
      cin >> u >> v >> c;
      toLCA(u, v, c);
      toLCA(v, u, c);
      cout << c << '\n';
    } else {
      cin >> u >> c;
      w[u] = c;
    }
  }
}
