#include <bits/stdc++.h>
using namespace std;
const int tope = 1 << 21;
const int primero = 1 << 20;
const int infinito = 1000000000;
int minimo[tope];
int suma[tope];
int maxsumari[tope];
long long int division[tope];
void inserta(int pos, int mini, int su, long long int divi) {
  if (divi == 1) su = 0;
  pos += primero;
  minimo[pos] = mini;
  suma[pos] = maxsumari[pos] = su;
  division[pos] = divi;
  while (pos > 1) {
    pos >>= 1;
    int pos0 = pos << 1;
    int pos1 = pos0 + 1;
    minimo[pos] = min(minimo[pos0], minimo[pos1]);
    suma[pos] = suma[pos0] + suma[pos1];
    maxsumari[pos] = max(maxsumari[pos1], maxsumari[pos0] + suma[pos1]);
  }
}
int minimoentre(int pos0, int pos1) {
  if (pos0 > pos1) swap(pos0, pos1);
  pos0 += primero;
  pos1 += primero;
  if (pos0 == pos1) return minimo[pos0];
  int mini = min(minimo[pos0], minimo[pos1]);
  while (pos0 + 1 < pos1) {
    if ((pos0 & 1) == 0) mini = min(mini, minimo[pos0 + 1]);
    pos0 >>= 1;
    if ((pos1 & 1) == 1) mini = min(mini, minimo[pos1 - 1]);
    pos1 >>= 1;
  }
  return mini;
}
int anterior(int pos) {
  int sum = 0;
  for (;;) {
    if (pos == 1) return -1;
    if ((pos & 1) == 1) {
      if (maxsumari[pos - 1] + sum > 0) {
        pos--;
        while (pos < primero) {
          int pos0 = pos << 1;
          int pos1 = pos0 + 1;
          if (maxsumari[pos1] + sum > 0)
            pos = pos1;
          else {
            sum += suma[pos1];
            pos = pos0;
          }
        }
        return pos;
      }
      sum += suma[pos - 1];
    }
    pos >>= 1;
  }
}
vector<long long int> genera(int pos, int mini) {
  pos += primero;
  pos = anterior(pos);
  vector<long long int> v;
  while (pos != -1 and mini <= minimo[pos] and int(v.size()) < 64) {
    v.push_back(division[pos]);
    pos = anterior(pos);
  }
  return v;
}
struct arista {
  int v, ind;
  long long int x;
  arista() {}
  arista(int inv, int inind, long long int inx) {
    v = inv;
    ind = inind;
    x = inx;
  }
};
int n, m;
vector<arista> g[1000000];
int posicion[1000000];
int posi = 0;
int arista2pos[1000000];
int arista2neg[1000000];
int arista2prof[1000000];
void genera(int u, int p, int prof) {
  posicion[u] = posi;
  inserta(posi++, prof, 0, 1);
  vector<arista> &ar = g[u];
  for (int i = 0; i < int(ar.size()); i++) {
    int v = ar[i].v;
    long long int x = ar[i].x;
    int ind = ar[i].ind;
    if (v != p) {
      arista2pos[ind] = posi;
      arista2prof[ind] = prof;
      inserta(posi++, prof, 1, x);
      genera(v, u, prof + 1);
      arista2neg[ind] = posi;
      inserta(posi++, prof, -1, x);
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 1; i <= n - 1; i++) {
    int u, v;
    long long int x;
    cin >> u >> v >> x;
    g[u].push_back(arista(v, i, x));
    g[v].push_back(arista(u, i, x));
  }
  genera(1, 0, 0);
  for (int caso = 0; caso < m; caso++) {
    int tipo;
    cin >> tipo;
    if (tipo == 2) {
      int ind;
      long long int x;
      cin >> ind >> x;
      inserta(arista2pos[ind], arista2prof[ind], 1, x);
      inserta(arista2neg[ind], arista2prof[ind], -1, x);
    } else {
      int a, b;
      long long int y;
      cin >> a >> b >> y;
      int mini = minimoentre(posicion[a], posicion[b]);
      vector<long long int> va = genera(posicion[a], mini);
      vector<long long int> vb = genera(posicion[b], mini);
      if (int(va.size()) + int(vb.size()) >= 64) {
        cout << 0 << endl;
      } else {
        reverse(vb.begin(), vb.end());
        for (int i = 0; i < int(vb.size()); i++) va.push_back(vb[i]);
        for (int i = 0; i < int(va.size()); i++) y /= va[i];
        cout << y << endl;
      }
    }
  }
}
