#include <bits/stdc++.h>
using namespace std;
mt19937 gen(time(NULL));
const double eps = 1e-9;
const int inf = 1e9;
const int mod = 1e9 + 7;
const unsigned long long infinity = 2 * 1e18 + 3;
int n, m;
vector<int> g[200501];
map<pair<int, int>, unsigned long long> w;
int p2[200501], s[200501];
int hld[200501], lnm[200501];
vector<int> path[200501];
int pn = 0;
unsigned long long valup[200501];
class st {
 public:
  vector<unsigned long long> t;
  vector<int> x;
  int n;
  st() {}
  st(int n, vector<int> &e) : n(n) {
    for (int i = 0; i < 4 * n; i++) t.push_back(0);
    for (auto v : e) x.push_back(v);
    build(0, 0, n);
  }
  void build(int u, int l, int r) {
    if (l == r - 1) return void(t[u] = valup[x[l]]);
    int m = ((l + r) / 2);
    build(2 * u + 1, l, m);
    build(2 * u + 2, m, r);
    t[u] = t[2 * u + 1];
    if (t[u] <= infinity / t[2 * u + 2])
      t[u] *= t[2 * u + 2];
    else
      t[u] = infinity;
  }
  void upd(int u, int l, int r, int p2, unsigned long long v) {
    if (l == r - 1) return void(t[u] = v);
    int m = ((l + r) / 2);
    if (p2 < m)
      upd(2 * u + 1, l, m, p2, v);
    else
      upd(2 * u + 2, m, r, p2, v);
    t[u] = t[2 * u + 1];
    if (t[u] <= infinity / t[2 * u + 2])
      t[u] *= t[2 * u + 2];
    else
      t[u] = infinity;
  }
  unsigned long long get(int u, int l, int r, int L, int R) {
    if (L >= R) return 0;
    if (l == L && r == R) return t[u];
    int m = ((l + r) / 2);
    unsigned long long sum = 1;
    if (L < m) sum *= get(2 * u + 1, l, m, L, min(m, R));
    if (R > m) {
      unsigned long long ret = get(2 * u + 2, m, r, max(L, m), R);
      if (ret <= infinity / sum)
        sum *= ret;
      else
        sum = infinity;
    }
    return sum;
  }
};
st pt[200501];
bool light(int u) { return 2 * s[u] < s[p2[u]]; }
void r8(int u, int num) {
  hld[u] = pn, lnm[u] = num;
  path[pn].push_back(u);
  if (u && !light(u)) r8(p2[u], num + 1);
}
void split(int u, int e) {
  for (auto v : g[u])
    if (v != e) split(v, u);
  bool flag = false;
  for (auto v : g[u])
    if (v != e) flag |= (!light(v));
  if (!flag) r8(u, 0), pn++;
}
int dfs(int u, int e) {
  p2[u] = e, s[u] = 1;
  if (u) valup[u] = w[make_pair(u, e)];
  for (auto v : g[u])
    if (v != e) s[u] += dfs(v, u);
  return s[u];
}
unsigned long long get(int u, int lca) {
  if (u == lca) return 1;
  if (hld[u] != hld[lca]) {
    unsigned long long local_sum =
        pt[hld[u]].get(0, 0, pt[hld[u]].n, lnm[u], pt[hld[u]].n);
    u = path[hld[u]].back();
    {
      unsigned long long local = get(p2[u], lca);
      if (local <= infinity / local_sum)
        return local * local_sum;
      else
        return infinity;
    }
  } else
    return pt[hld[u]].get(0, 0, pt[hld[u]].n, lnm[u], lnm[lca]);
}
pair<int, int> edges[200501];
int dyn[200501][20];
int lv[200501];
void dfs2(int u, int e) {
  dyn[u][0] = e;
  for (int i = 1; i <= 20 - 1; i++) dyn[u][i] = dyn[dyn[u][i - 1]][i - 1];
  lv[u] = lv[e] + 1;
  for (auto v : g[u])
    if (v != e) dfs2(v, u);
}
int lca(int u, int v) {
  if (u == v) return u;
  if (lv[u] > lv[v]) swap(u, v);
  int dl = lv[v] - lv[u];
  for (int i = 0; i < 20; i++)
    if ((dl >> i) & 1) v = dyn[v][i];
  if (u == v) return v;
  if (v != u)
    for (int i = 20 - 1; i >= 0; i--)
      if (dyn[v][i] != dyn[u][i]) v = dyn[v][i], u = dyn[u][i];
  return dyn[v][0];
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  int u, v;
  unsigned long long wei;
  for (int i = 0; i < n - 1; i++) {
    cin >> u >> v >> wei;
    u--, v--;
    w[make_pair(u, v)] = wei, w[make_pair(v, u)] = wei;
    g[u].push_back(v), g[v].push_back(u);
    edges[i] = make_pair(u, v);
  }
  for (int i = 0; i < n; i++) valup[i] = 1;
  dfs(0, 0);
  split(0, 0);
  dfs2(0, 0);
  for (int i = 0; i < n - 1; i++)
    if (p2[edges[i].first] != edges[i].second)
      swap(edges[i].first, edges[i].second);
  for (int i = 0; i < pn; i++) pt[i] = st(path[i].size(), path[i]);
  int x, a, l, r;
  for (int i = 0; i < m; i++) {
    unsigned long long val;
    cin >> x;
    if (x == 2) {
      cin >> a >> val;
      a--;
      pt[hld[edges[a].first]].upd(0, 0, pt[hld[edges[a].first]].n,
                                  lnm[edges[a].first], val);
    } else {
      cin >> l >> r >> val;
      l--, r--;
      int anc = lca(l, r);
      unsigned long long retl = get(l, anc), retr = get(r, anc);
      unsigned long long res =
          (retl <= infinity / retr) ? retr * retl : infinity;
      printf("%I64d\n", val / res);
    }
  }
}
