#include <bits/stdc++.h>
using namespace std;
int id;
long long w[200000 + 100];
int f[200000 + 100];
int p[200000 + 100];
int in[200000 + 100];
int out[200000 + 100];
vector<pair<int, int> > g[200000 + 100];
void dfs(int u) {
  int i;
  in[u] = ++id;
  for (const auto &x : g[u]) {
    if (x.first == p[u]) continue;
    p[x.first] = u;
    f[x.first] = x.second;
    dfs(x.first);
  }
  out[u] = id;
}
int go(int u) { return w[f[u]] == 1 ? p[u] = go(p[u]) : u; }
void calc(int u, int v, long long &c) {
  if (!u || !c) return;
  if (in[u] <= in[v] && out[u] >= out[v]) return;
  c /= w[f[u]];
  calc(p[u] = go(p[u]), v, c);
}
int main() {
  int i, j, k;
  int n, m;
  int u, v;
  long long c;
  cin >> n >> m;
  for (i = 0; i < n - 1; i++) {
    scanf("%d%d%I64d", &u, &v, &c);
    w[i + 1] = c;
    g[u].emplace_back(v, i + 1);
    g[v].emplace_back(u, i + 1);
  }
  dfs(1);
  for (i = 0; i < m; i++) {
    int type;
    scanf("%d", &type);
    if (type == 1) {
      scanf("%d%d%I64d", &u, &v, &c);
      calc(u, v, c);
      calc(v, u, c);
      printf("%I64d\n", c);
    } else {
      scanf("%d%I64d", &u, &c);
      w[u] = c;
    }
  }
  return 0;
}
