#include <bits/stdc++.h>
using namespace std;
void fre() {
  freopen("c://test//input.in", "r", stdin);
  freopen("c://test//output.out", "w", stdout);
}
template <class T>
inline void gmax(T &a, T b) {
  if (b > a) a = b;
}
template <class T>
inline void gmin(T &a, T b) {
  if (b < a) a = b;
}
const int N = 2e5 + 10, M = 4e5 + 10, Z = 1e9 + 7, ms63 = 1061109567;
int n, m, id;
int x, y, o;
long long z;
int lca;
long long W;
int first[N], w[M], nxt[M];
long long c[M];
int dep[N], v[N], f[N];
long long dis[N];
int b[20], fa[N][20];
void ins(int x, int y, long long z) {
  ++id;
  w[id] = y;
  c[id] = z;
  nxt[id] = first[x];
  first[x] = id;
}
void dfs(int x) {
  for (int z = first[x]; z; z = nxt[z]) {
    int y = w[z];
    if (y == fa[x][0]) continue;
    fa[y][0] = x;
    v[z >> 1] = y;
    dis[y] = c[z];
    dep[y] = dep[x] + 1;
    dfs(y);
  }
}
void LCAinit() {
  for (int j = 1; b[j] < n; j++) {
    for (int i = 1; i <= n; i++)
      if (~fa[i][j - 1]) {
        fa[i][j] = fa[fa[i][j - 1]][j - 1];
      }
  }
}
int LCA(int x, int y) {
  int i, j;
  if (dep[x] < dep[y]) swap(x, y);
  for (i = 0; b[i] <= dep[x]; i++)
    ;
  i--;
  for (j = i; dep[x] > dep[y]; j--)
    if (dep[x] - b[j] >= dep[y]) x = fa[x][j];
  if (x == y) return x;
  for (j = i; fa[x][0] != fa[y][0]; j--)
    if (fa[x][j] != fa[y][j]) {
      x = fa[x][j];
      y = fa[y][j];
    }
  return fa[x][0];
}
int find(int x) {
  if (f[x] == x) return f[x];
  f[x] = find(f[x]);
  return f[x];
}
void go(int x) {
  while (1) {
    x = find(x);
    if (dep[x] <= dep[lca]) return;
    W /= dis[x];
    if (W == 0) return;
    x = fa[x][0];
  }
}
int main() {
  int T = 0;
  for (int i = 0; i < 20; i++) b[i] = 1 << i;
  while (~scanf("%d%d", &n, &m)) {
    memset(first, 0, sizeof(first));
    id = 1;
    for (int i = 1; i < n; i++) {
      scanf("%d%d%lld", &x, &y, &z);
      ins(x, y, z);
      ins(y, x, z);
    }
    memset(fa, -1, sizeof(fa));
    dfs(1);
    LCAinit();
    for (int i = 1; i <= n; i++) f[i] = i;
    for (int i = 2; i <= n; i++) {
      if (dis[i] == 1) f[i] = fa[i][0];
    }
    for (int i = 1; i <= n; i++) f[i] = find(i);
    for (int i = 1; i <= m; i++) {
      scanf("%d", &o);
      if (o == 1) {
        scanf("%d%d%lld", &x, &y, &W);
        lca = LCA(x, y);
        go(x);
        go(y);
        printf("%lld\n", W);
      } else {
        scanf("%d%lld", &x, &W);
        x = v[x];
        long long ori = dis[x];
        dis[x] = W;
        if (ori != 1 && W == 1) f[x] = fa[x][0];
      }
    }
  }
  return 0;
}
