#include <bits/stdc++.h>
using namespace std;
const int INF = (int)1e9 + 7, mod = (int)1e9 + 9, pw = 31, N = (int)2e5 + 123,
          M = (int)1e6 + 123;
const double eps = 1e-11;
const long long inf = 2e18;
struct node {
  long long a;
  int in, out, sz, up[22], block;
  int l, r;
  vector<pair<int, long long>> edge;
  node() {}
} a[N];
double t[4 * N], d[N];
pair<int, int> edge[N];
int n, m;
vector<int> path;
inline bool check(int u, int v) {
  return (a[u].in <= a[v].in && a[u].out >= a[v].out);
}
void dfs(int v, int p = -1) {
  static int cnt = 0;
  a[v].in = ++cnt;
  a[v].up[0] = p == -1 ? v : p;
  a[v].sz = 1;
  for (int i = 1; i <= 19; i++) {
    a[v].up[i] = a[a[v].up[i - 1]].up[i - 1];
  }
  for (int i = 0, to; i < a[v].edge.size(); i++) {
    if ((to = a[v].edge[i].first) != p) {
      dfs(to, v);
      a[v].sz += a[to].sz;
    } else
      d[v] = a[v].edge[i].second;
  }
  a[v].out = ++cnt;
}
int lca(int u, int v) {
  if (check(u, v)) return u;
  if (check(v, u)) return v;
  for (int i = 19; i >= 0; i--) {
    if (!check(a[u].up[i], v)) {
      u = a[u].up[i];
    }
  }
  return a[u].up[0];
}
void buildHLD(int v, int p = -1) {
  int maxi = 0;
  static int cnt = 0;
  for (int i = 0, to; i < a[v].edge.size(); i++) {
    if ((to = a[v].edge[i].first) != p) {
      if (a[to].sz + a[to].sz >= a[v].sz)
        maxi = to;
      else
        buildHLD(to, v);
    }
  }
  if (maxi) {
    buildHLD(maxi, v);
    a[v].block = a[maxi].block;
  } else
    a[v].block = ++cnt;
  path.push_back(v);
}
void build(int v = 1, int l = 1, int r = n) {
  if (l > r) return;
  if (l == r) {
    t[v] = d[path[l - 1]];
    return;
  }
  int mid = (l + r) / 2;
  build(v + v, l, mid);
  build(v + v + 1, mid + 1, r);
  t[v] = t[v + v] * t[v + v + 1];
  if (t[v] > inf) t[v] = inf;
}
void upd(int id, long long x, int v = 1, int tl = 1, int tr = n) {
  if (tl > tr) return;
  if (tl == tr) {
    t[v] = x;
    a[tl].a = x;
    return;
  }
  int mid = (tl + tr) / 2;
  if (id <= mid)
    upd(id, x, v + v, tl, mid);
  else
    upd(id, x, v + v + 1, mid + 1, tr);
  t[v] = t[v + v] * t[v + v + 1];
  if (t[v] > inf) t[v] = inf;
}
double get(int l, int r, int v = 1, int tl = 1, int tr = n) {
  if (tl > tr || tl > r || tr < l || l > r) return 1.;
  if (l <= tl && tr <= r) return t[v];
  int mid = (tl + tr) / 2;
  return get(l, r, v + v, tl, mid) * get(l, r, v + v + 1, mid + 1, tr);
}
double Get(int l, int r) {
  if (l == r) return 1ll;
  double res = 1;
  for (int i = l;; i = a[path[a[i].r - 1]].up[0]) {
    int L = a[i].l, R = a[i].r;
    if (L <= a[r].l && a[r].l <= R) R = a[r].l - 1;
    res *= get(L, R);
    if (res > inf) return inf;
    if (R == a[r].l - 1) break;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cin >> n >> m;
  for (int i = 0; i <= n + 1; i++) d[i] = 1;
  for (int i = 1; i < n; i++) {
    long long u, v, x;
    cin >> u >> v >> x;
    a[u].edge.push_back({v, x});
    a[v].edge.push_back({u, x});
    edge[i] = make_pair(u, v);
  }
  dfs(1);
  buildHLD(1);
  for (int j = (int)path.size() - 1, i = path[j]; j >= 0; j--, i = path[j]) {
    a[i].l = j + 1;
    a[i].r = j + 1;
    if (j + 1 < path.size() && a[i].block == a[path[j + 1]].block)
      a[i].r = a[path[j + 1]].r;
  }
  build();
  for (int i = 1; i <= m; i++) {
    int c;
    long long u, v;
    cin >> c >> u >> v;
    if (c == 2) {
      int l = edge[u].first;
      int r = edge[u].second;
      if (a[l].up[0] == r)
        upd(a[l].l, v);
      else
        upd(a[r].l, v);
    } else {
      long long x;
      cin >> x;
      double res = Get(u, lca(u, v)) * Get(v, lca((int)u, (int)v));
      if (res > inf) res = inf;
      cout << x / (long long)res << "\n";
    }
  }
  return 0;
}
