#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 62;
inline long long mult(long long a, long long b) {
  long long r = a * b;
  if (a != 0 && r / a != b) return INF;
  return r;
}
int n, m;
int u[200000 + 100];
int v[200000 + 100];
long long x[200000 + 100];
vector<int> adj[200000 + 100];
vector<int> e[200000 + 100];
vector<vector<long long> > seg;
bool vis[200000 + 100];
vector<int> chains[200000 + 100];
int c[200000 + 100];
int hd[200000 + 100];
int h[200000 + 100];
int p[200000 + 100];
int nc = 0;
int inv[200000 + 100];
int dfs(int i, int pr = 0, int ht = 0) {
  if (vis[i]) return 0;
  vis[i] = true;
  p[i] = pr;
  h[i] = ht;
  int sz = 1;
  int mn = 0;
  int sc = -1;
  for (int j = 0; j < adj[i].size(); ++j) {
    int cs = dfs(adj[i][j], e[i][j], 1 + ht);
    sz += cs;
    if (cs > mn) {
      mn = cs;
      sc = j;
    }
  }
  if (sc == -1) {
    c[i] = nc;
    hd[c[i]] = i;
    ++nc;
  } else {
    c[i] = c[adj[i][sc]];
    hd[c[i]] = i;
    chains[c[i]].push_back(e[i][sc]);
  }
  return sz;
}
long long build(int c, int f, int l, int in = 1) {
  if (f == l) return seg[c][in] = 1;
  if (f + 1 == l) {
    return seg[c][in] = x[chains[c][f]];
  }
  int m = (f + l) / 2;
  return seg[c][in] = mult(build(c, f, m, 2 * in), build(c, m, l, 2 * in + 1));
}
long long query(int ql, int qr, int c, int f, int l, int in = 1) {
  if (ql >= l || qr <= f) return 1;
  if (f >= ql && l <= qr) return seg[c][in];
  int m = (f + l) / 2;
  return mult(query(ql, qr, c, f, m, 2 * in),
              query(ql, qr, c, m, l, 2 * in + 1));
}
long long upd(int p, long long v, int c, int f, int l, int in = 1) {
  if (p >= l || p < f || f == l) return seg[c][in];
  if (f == p && l == f + 1) return seg[c][in] = v;
  if (f + 1 == l) return seg[c][in];
  int m = (f + l) / 2;
  return seg[c][in] =
             mult(upd(p, v, c, f, m, in * 2), upd(p, v, c, m, l, in * 2 + 1));
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 1; i < n; ++i) {
    cin >> u[i] >> v[i];
    adj[u[i]].push_back(v[i]);
    adj[v[i]].push_back(u[i]);
    e[u[i]].push_back(i);
    e[v[i]].push_back(i);
    cin >> x[i];
  }
  dfs(1);
  for (int i = 1; i < n; ++i)
    if (h[u[i]] > h[v[i]]) swap(u[i], v[i]);
  seg.resize(nc);
  for (int i = 0; i < nc; ++i) {
    seg[i].resize(chains[i].size() * 4 + 100);
    reverse(chains[i].begin(), chains[i].end());
    build(i, 0, chains[i].size());
    for (int j = 0; j < chains[i].size(); ++j) {
      inv[v[chains[i][j]]] = 1 + j;
    }
  }
  while (m--) {
    long long ch, ai, bi, yi, pi, ci;
    cin >> ch;
    if (ch == 2) {
      cin >> pi >> ci;
      if (c[u[pi]] == c[v[pi]]) {
        if (h[u[pi]] > h[v[pi]]) swap(u[pi], v[pi]);
        upd(inv[u[pi]], ci, c[u[pi]], 0, chains[c[u[pi]]].size());
      }
      x[pi] = ci;
    } else if (ch == 1) {
      cin >> ai >> bi >> yi;
      long long div = 1;
      while (c[ai] != c[bi]) {
        if (h[hd[c[ai]]] > h[hd[c[bi]]]) swap(ai, bi);
        if (inv[bi] == 0) {
          div = mult(div, x[p[bi]]);
          bi = u[p[bi]];
        } else {
          div = mult(div, query(0, inv[bi], c[bi], 0, chains[c[bi]].size()));
          bi = hd[c[bi]];
        }
      }
      if (inv[ai] > inv[bi]) swap(ai, bi);
      div = mult(div, query(inv[ai], inv[bi], c[ai], 0, chains[c[ai]].size()));
      cout << yi / div << endl;
    }
  }
  return 0;
}
