#include <bits/stdc++.h>
using namespace std;
const long long MAX = 1e18;
const int MAXN = 4e5 + 5;
int n, m;
struct Tree {
  int father, num, son[2];
  long long sum, val;
  bool tag;
} tree[MAXN];
void PushUp(int now) {
  if (tree[tree[now].son[0]].sum == -1 || tree[tree[now].son[1]].sum == -1) {
    tree[now].sum = -1;
    return;
  }
  if (tree[tree[now].son[0]].sum <= MAX / tree[tree[now].son[1]].sum) {
    tree[now].sum = tree[tree[now].son[0]].sum * tree[tree[now].son[1]].sum;
    if (tree[now].sum <= MAX / tree[now].val) {
      tree[now].sum *= tree[now].val;
    } else {
      tree[now].sum = -1;
    }
  } else {
    tree[now].sum = -1;
  }
}
void Down(int now) {
  tree[now].tag ^= 1;
  swap(tree[now].son[0], tree[now].son[1]);
}
void PushDown(int now) {
  if (tree[now].tag) {
    tree[now].tag = 0;
    Down(tree[now].son[0]);
    Down(tree[now].son[1]);
  }
}
bool Root(int now) {
  int father = tree[now].father;
  return !((tree[father].son[0] == now) || (tree[father].son[1] == now));
}
void PushRoot(int now) {
  if (!Root(now)) {
    PushRoot(tree[now].father);
  }
  PushDown(now);
}
void Rotate(int now) {
  int father = tree[now].father;
  int ffather = tree[father].father;
  PushDown(now);
  PushDown(father);
  bool fson = tree[father].son[1] == now;
  if (!Root(father)) {
    tree[ffather].son[tree[ffather].son[1] == father] = now;
  }
  tree[now].father = ffather;
  tree[father].son[fson] = tree[now].son[fson ^ 1];
  tree[tree[now].son[fson ^ 1]].father = father;
  tree[now].son[fson ^ 1] = father;
  tree[father].father = now;
  PushUp(now);
  PushUp(father);
}
void Splay(int now) {
  PushRoot(now);
  while (!Root(now)) {
    int father = tree[now].father;
    int ffather = tree[father].father;
    if (!Root(father)) {
      if ((tree[ffather].son[0] == father) ^ (tree[father].son[0] == now)) {
        Rotate(now);
      } else {
        Rotate(father);
      }
    }
    Rotate(now);
  }
  PushUp(now);
}
void Access(int now) {
  int last = 0;
  while (now) {
    Splay(now);
    tree[now].son[1] = last;
    PushUp(now);
    now = tree[last = now].father;
  }
}
void MakeRoot(int now) {
  Access(now);
  Splay(now);
  Down(now);
}
int FindRoot(int now) {
  Access(now);
  Splay(now);
  while (tree[now].son[0]) {
    PushDown(now);
    now = tree[now].son[0];
  }
  Splay(now);
  return now;
}
void Split(int u, int v) {
  MakeRoot(u);
  Access(v);
  Splay(v);
}
void Link(int u, int v) {
  MakeRoot(u);
  if (FindRoot(v) ^ u) {
    tree[u].father = v;
    tree[v].son[1] = u;
    PushUp(v);
  }
}
void Cut(int u, int v) {
  MakeRoot(u);
  if (FindRoot(v) == u && tree[v].father == u && !tree[v].son[0]) {
    tree[v].father = tree[u].son[1] = 0;
    PushUp(u);
  }
}
void Updata(int now, int num) {
  Splay(now);
  tree[now].val = num;
  PushUp(now);
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i <= n; ++i) {
    tree[i].sum = 1;
    tree[i].val = 1;
  }
  int u, v;
  long long val;
  for (int i = 1; i <= n - 1; ++i) {
    scanf("%d%d%lld", &u, &v, &val);
    tree[n + i].val = val;
    Link(u, n + i);
    Link(n + i, v);
  }
  int opt;
  for (int i = 1; i <= m; ++i) {
    scanf("%d", &opt);
    if (opt == 1) {
      scanf("%d%d%lld", &u, &v, &val);
      Split(u, v);
      if (tree[v].sum == -1) {
        printf("0\n");
      } else {
        printf("%lld\n", val / tree[v].sum);
      }
    }
    if (opt == 2) {
      scanf("%d%lld", &u, &val);
      Split(n + u, n + u);
      tree[n + u].val = val;
      tree[n + u].sum = val;
    }
  }
  return 0;
}
