#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 10;
const int LOG = 19;
int pred[LOG][MAXN], gp[MAXN];
long long eddiv[MAXN], updiv[MAXN];
int downVert[MAXN];
int d[MAXN], tin[MAXN], tout[MAXN];
bool used[MAXN];
int timer = 0;
void dfs(int v, int p, vector<vector<pair<int, int>>>& gr) {
  tin[v] = ++timer;
  used[v] = true;
  for (int i = 0; i < (int)gr[v].size(); ++i) {
    int to = gr[v][i].first, ed = gr[v][i].second;
    if (!used[to]) {
      d[to] = d[v] + 1;
      downVert[ed] = to;
      updiv[to] = eddiv[ed];
      pred[0][to] = v;
      gp[to] = p;
      if (eddiv[ed] > 1) {
        dfs(to, to, gr);
      } else {
        dfs(to, p, gr);
      }
    }
  }
  tout[v] = ++timer;
}
void buildTable(int n) {
  for (int i = 1; i < LOG; ++i) {
    for (int j = 1; j <= n; ++j) {
      pred[i][j] = pred[i - 1][pred[i - 1][j]];
    }
  }
}
bool isPar(int a, int b) { return tin[a] <= tin[b] && tout[a] >= tout[b]; }
int lca(int a, int b) {
  if (d[a] < d[b]) swap(a, b);
  for (int i = LOG - 1; i >= 0; --i) {
    if (d[a] - (1 << i) >= 0 && !isPar(pred[i][a], b)) a = pred[i][a];
  }
  if (!isPar(a, b)) a = pred[0][a];
  return a;
}
int getGp(int v) {
  if (updiv[v] > 1 || v == 0) return v;
  return gp[v] = getGp(gp[v]);
}
void upd(int v, long long val) {
  updiv[v] = val;
  gp[v] = getGp(gp[v]);
}
long long go(int a, int b, long long y) {
  if (a == b) return y;
  int rt = lca(a, b);
  while (y > 0 && d[a] > d[rt]) {
    y /= updiv[a];
    gp[a] = getGp(gp[a]);
    a = gp[a];
  }
  while (y > 0 && d[b] > d[rt]) {
    y /= updiv[b];
    gp[b] = getGp(gp[b]);
    b = gp[b];
  }
  return y;
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  vector<vector<pair<int, int>>> gr(n + 1);
  for (int i = 1; i < n; ++i) {
    int u, v;
    scanf("%d%d%I64d", &u, &v, &eddiv[i]);
    gr[u].push_back(make_pair(v, i));
    gr[v].push_back(make_pair(u, i));
  }
  dfs(1, 0, gr);
  buildTable(n);
  for (int i = 0; i < m; ++i) {
    int tp;
    scanf("%d", &tp);
    if (tp == 1) {
      int a, b;
      long long y;
      scanf("%d%d%I64d", &a, &b, &y);
      printf("%I64d\n", go(a, b, y));
    } else {
      int ed;
      long long ny;
      scanf("%d%I64d", &ed, &ny);
      upd(downVert[ed], ny);
    }
  }
  return 0;
}
