#include <bits/stdc++.h>
using namespace std;
constexpr int MAXN = 200000;
int ledge[MAXN + 2];
long long x[MAXN + 2];
long long initv[MAXN + 2];
int depth[MAXN + 2];
int dp[MAXN + 2];
vector<pair<int, int>> adj[MAXN + 2];
void dfs(int u, int w, int k) {
  dp[u] = w;
  depth[u] = k;
  for (pair<int, int> vi : adj[u]) {
    int v = vi.first;
    if (v == w) continue;
    ledge[vi.second] = v;
    dfs(v, u, k + 1);
  }
}
int find(int u) { return x[dp[u]] >= 2 ? dp[u] : (dp[u] = find(dp[u])); }
int main() {
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n - 1; i++) {
    int u, v;
    cin >> u >> v >> initv[i];
    adj[u].push_back(make_pair(v, i));
    adj[v].push_back(make_pair(u, i));
  }
  x[1] = 2;
  dfs(1, 0, 0);
  for (int i = 1; i <= n - 1; i++) x[ledge[i]] = initv[i];
  for (int i = 0; i < m; i++) {
    int op;
    cin >> op;
    if (op == 1) {
      int a, b;
      long long y;
      cin >> a >> b >> y;
      while (a != b) {
        if (depth[a] > depth[b]) {
          if (!(y /= x[a])) break;
          a = find(a);
        } else {
          if (!(y /= x[b])) break;
          b = find(b);
        }
      }
      cout << y << '\n';
    } else {
      int p;
      long long c;
      cin >> p >> c;
      x[ledge[p]] = c;
    }
  }
}
