#include <bits/stdc++.h>
using namespace std;
int m;
const int MN = 200010;
vector<vector<pair<int, long long> > > g;
vector<pair<int, int> > edg;
int p[MN], lev[MN];
long long w[MN];
int n, l;
vector<vector<int> > G;
vector<int> tin, tout;
int timer;
vector<vector<int> > up;
void DFS(int v, int P = 0) {
  tin[v] = ++timer;
  up[v][0] = P;
  for (int i = 1; i <= l; i++) up[v][i] = up[up[v][i - 1]][i - 1];
  for (size_t i = 0; i < G[v].size(); i++) {
    int to = G[v][i];
    if (to != P) DFS(to, v);
  }
  tout[v] = ++timer;
}
bool upper(int a, int b) { return tin[a] <= tin[b] && tout[a] >= tout[b]; }
int lca(int a, int b) {
  if (upper(a, b)) return a;
  if (upper(b, a)) return b;
  for (int i = l; i >= 0; --i)
    if (!upper(up[a][i], b)) a = up[a][i];
  return up[a][0];
}
void dfss(int u, int L) {
  lev[u] = L;
  for (int i = 0, v; i < (int)g[u].size(); ++i) {
    v = g[u][i].first;
    if (p[v] == -1) {
      if (g[u][i].second == 1 and w[u] == 1 and u != 0)
        p[v] = p[u];
      else
        p[v] = u;
      w[v] = g[u][i].second;
      dfss(v, L + 1);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  scanf("%d", &n);
  scanf("%d", &m);
  long long x;
  g.resize(n + 10);
  G.resize(n + 10);
  for (int i = 0, u, v; i < n - 1; ++i) {
    scanf("%d%d%I64d", &u, &v, &x);
    --u, --v;
    g[u].push_back(make_pair(v, x));
    g[v].push_back(make_pair(u, x));
    G[u].push_back(v);
    G[v].push_back(u);
    edg.push_back(make_pair(u, v));
  }
  tin.resize(n), tout.resize(n), up.resize(n);
  l = 1;
  while ((1 << l) <= n) ++l;
  for (int i = 0; i < n; i++) up[i].resize(l + 1);
  DFS(0);
  memset(p, -1, sizeof p);
  p[0] = n + 1;
  w[0] = 1;
  lev[n + 1] = -1;
  dfss(0, 1);
  for (int i = 0, d, a, b, pp, lcal; i < m; ++i) {
    scanf("%d", &d);
    if (d == 1) {
      scanf("%d%d%I64d", &a, &b, &x);
      --a, --b;
      lcal = lev[lca(a, b)];
      while (lev[p[b]] >= lcal && x) {
        pp = b;
        x /= w[b], b = p[b];
        if (w[b] == 1 && w[pp] == 1 && b != 0) p[pp] = p[b];
      }
      while (lev[p[a]] >= lcal && x) {
        pp = a;
        x /= w[a], a = p[a];
        if (w[a] == 1 && w[pp] == 1 && a != 0) p[pp] = p[a];
      }
      printf("%I64d\n", x);
    } else {
      scanf("%d%I64d", &pp, &x);
      --pp;
      a = edg[pp].first;
      b = edg[pp].second;
      if (!(p[b] == a)) swap(a, b);
      if (x == 1 and w[p[b]] == 1 and p[b] != 0) p[b] = p[p[b]];
      w[b] = x;
    }
  }
}
