#include <bits/stdc++.h>
using namespace std;
vector<pair<int, long long> > G[200003];
int parent[200003];
int depth[200003];
long long ww[200003];
pair<int, int> edges[200003];
int ff[200003];
int m, n, t, a, b, p;
void dfs(int u, int f, int d) {
  parent[u] = f;
  depth[u] = d;
  for (int i = 0; i < G[u].size(); i++) {
    int v = G[u][i].first;
    if (v == f) continue;
    ww[v] = G[u][i].second;
    if (ww[v] > 1)
      ff[v] = v;
    else
      ff[v] = ff[u];
    dfs(v, u, d + 1);
  }
}
int F(int u) {
  if (u == 1) return 1;
  if (ww[u] > 1) return ff[u];
  int f = F(ff[u]);
  ff[u] = f;
  return ff[u];
}
void init_tree(int n) {
  ww[1] = 1;
  ff[1] = 1;
  dfs(1, 0, 0);
}
long long get_y(int a, int b, long long y) {
  while (a != b && y > 0) {
    if (depth[a] < depth[b]) swap(a, b);
    if (ww[a] > 1) {
      y /= ww[a];
      a = parent[a];
    } else
      a = F(a);
  }
  return y;
}
int main() {
  long long y, c;
  scanf("%d%d", &n, &m);
  for (int i = 1; i < n; i++) {
    int u, v;
    long long w;
    scanf("%d%d%I64d", &u, &v, &w);
    G[u].push_back(make_pair(v, w));
    G[v].push_back(make_pair(u, w));
    edges[i] = make_pair(u, v);
  }
  init_tree(n);
  for (int i = 0; i < m; i++) {
    scanf("%d", &t);
    if (t == 1) {
      scanf("%d%d%I64d", &a, &b, &y);
      printf("%I64d\n", get_y(a, b, y));
    } else {
      scanf("%d%I64d", &p, &c);
      int u = edges[p].first;
      int v = edges[p].second;
      if (parent[v] == u) swap(u, v);
      ww[u] = c;
      if (ww[u] == 1) ff[u] = ff[v];
    }
  }
  return 0;
}
