#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void smax(T &x, T y) {
  x = max((x), (y));
}
template <class T>
inline void smin(T &x, T y) {
  x = min((x), (y));
}
const int MOD = 1e9 + 7;
const int SIZE = 2 * 1e5 + 10;
const int INF = 0x3f3f3f3f;
const int LOGSIZE = 20;
int n, m;
vector<pair<pair<int, int>, long long> > edges;
vector<vector<int> > g;
int dfsnum[SIZE], level[SIZE], num;
pair<int, long long> par[SIZE];
pair<int, long long> *npar[SIZE];
int dppar[SIZE][LOGSIZE];
int other(int e, int u) {
  if (edges[e].first.first == u) return edges[e].first.second;
  return edges[e].first.first;
}
void dfs(int u, int p, int h = 0) {
  par[u].first = p;
  dfsnum[u] = num++;
  level[u] = h;
  for (int i = 0; i < (((int)(g[u]).size())); ++i) {
    int v = other(g[u][i], u);
    if (v == p) {
      par[u].second = edges[g[u][i]].second;
      continue;
    }
    dfs(v, u, h + 1);
  }
  npar[u] = &par[u];
}
pair<int, long long> *nextpar(int u) {
  if (npar[u]->first == -1) return npar[u];
  if (npar[u]->second == 1) return npar[u] = nextpar(npar[u]->first);
  return npar[u];
}
void build_lca() {
  memset((dppar), -1, sizeof((dppar)));
  for (int i = 0; i < (n); ++i) dppar[i][0] = par[i].first;
  for (int log = (1); log < (LOGSIZE); ++log)
    for (int i = 0; i < (n); ++i) {
      if (dppar[i][log - 1] == -1)
        dppar[i][log] = -1;
      else {
        dppar[i][log] = dppar[dppar[i][log - 1]][log - 1];
      }
    }
}
int lca(int u, int v) {
  if (u == v) return u;
  if (level[u] < level[v]) swap(u, v);
  int diff = level[u] - level[v];
  for (int i = 0; i < (LOGSIZE); ++i)
    if (diff & (1 << i)) {
      u = dppar[u][i];
    }
  if (u == v) return u;
  for (int i = (LOGSIZE - 1); i >= 0; --i) {
    if (dppar[u][i] == -1) continue;
    if (dppar[u][i] == dppar[v][i]) continue;
    u = dppar[u][i];
    v = dppar[v][i];
  }
  return dppar[u][0];
}
int main() {
  if (0) {
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
  }
  while (scanf("%d%d", &(n), &(m)) == 2) {
    num = 0;
    edges.resize(n - 1);
    g.clear();
    g.resize(n);
    for (int i = 0; i < (n - 1); ++i) {
      int u, v;
      long long c;
      scanf("%d%d%I64d", &u, &v, &c);
      u--;
      v--;
      edges[i] = make_pair(make_pair(u, v), c);
      g[u].push_back(i);
      g[v].push_back(i);
    }
    dfs(0, -1, 0);
    build_lca();
    for (int i = 0; i < (m); ++i) {
      int a, b, p;
      long long y, c;
      int t;
      scanf("%d", &(t));
      if (t == 1) {
        scanf("%d%d%I64d", &a, &b, &y);
        a--;
        b--;
        int l = lca(a, b);
        stack<long long> st;
        while (y > 0 && nextpar(a)->first >= 0 &&
               level[nextpar(a)->first] >= level[l]) {
          y /= nextpar(a)->second;
          a = nextpar(a)->first;
        }
        while (y > 0 && ((int)(st).size()) < 60 && nextpar(b)->first >= 0 &&
               level[nextpar(b)->first] >= level[l]) {
          st.push(nextpar(b)->second);
          b = nextpar(b)->first;
        }
        while (((int)(st).size())) {
          y /= st.top();
          st.pop();
        }
        printf("%I64d\n", y);
      } else {
        scanf("%d%I64d", &p, &c);
        p--;
        edges[p].second = c;
        int a = edges[p].first.first, b = edges[p].first.second;
        if (level[a] > level[b]) {
          par[a].second = c;
        } else {
          par[b].second = c;
        }
      }
    }
  }
  return 0;
}
