#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 100;
struct Edge {
  long long v, c, next;
  Edge() {}
  Edge(long long v, long long c, long long next) : v(v), c(c), next(next) {}
} edge[N * 2];
long long n, m, p[N], edn, f[N], dep[N], u[N], v[N], c[N], e[N], fa[N];
void addedge(long long u, long long v, long long c) {
  edge[edn] = Edge(v, c, p[u]);
  p[u] = edn++;
}
long long ff(int x) {
  if (f[x] != x) f[x] = ff(f[x]);
  return f[x];
}
void dfs(long long x, long long FA, long long c) {
  e[x] = c;
  fa[x] = FA;
  if (c != 1)
    f[x] = x;
  else
    f[x] = f[FA];
  dep[x] = dep[FA] + 1;
  for (int i = p[x]; ~i; i = edge[i].next) {
    long long y = edge[i].v;
    if (y != FA) dfs(y, x, edge[i].c);
  }
}
int main() {
  cin >> n >> m;
  edn = 0;
  memset(p, -1, sizeof(p));
  for (int i = 1; i < n; i++) {
    scanf("%I64d%I64d%I64d", &u[i], &v[i], &c[i]);
    addedge(u[i], v[i], c[i]);
    addedge(v[i], u[i], c[i]);
  }
  dfs(1, 0, 1);
  for (int ii = 1; ii <= m; ii++) {
    int type;
    scanf("%d", &type);
    if (type == 1) {
      long long a, b, t;
      scanf("%I64d%I64d%I64d", &a, &b, &t);
      vector<long long> num_a, num_b;
      num_a.clear();
      num_b.clear();
      int tot = 0;
      while (true) {
        int ta = ff(a), tb = ff(b);
        if (ta == tb) break;
        if (dep[ta] > dep[tb]) {
          num_a.push_back(e[ta]);
          a = fa[ta];
          tot++;
        } else {
          num_b.push_back(e[tb]);
          b = fa[tb];
          tot++;
        }
        if (tot > 65) break;
      }
      if (tot > 65)
        puts("0");
      else {
        for (int i = 0; i < (int)num_a.size(); i++) t /= num_a[i];
        for (int i = (int)num_b.size() - 1; i >= 0; i--) t /= num_b[i];
        printf("%I64d\n", t);
      }
    } else {
      long long t, new_c;
      scanf("%I64d%I64d", &t, &new_c);
      long long x = u[t], y = v[t];
      if (dep[x] < dep[y]) swap(x, y);
      e[x] = new_c;
      if (e[x] == 1) f[x] = ff(y);
    }
  }
  return 0;
}
