#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
const int M = 15;
const long long MOD = 1000000007LL;
const double EPS = 1e-8;
int n, m;
vector<pair<long long, long long> > edge[N], edge_ord;
struct Node {
  int fa, non_one;
  long long val;
  vector<long long> child;
};
Node tree[N];
void build_tree(int u, long long val, int fa) {
  tree[u].fa = fa;
  tree[u].val = val;
  int s = edge[u].size();
  for (int i = 0; i < s; i++) {
    int v = edge[u][i].first;
    long long w = edge[u][i].second;
    if (v == fa) {
      continue;
    }
    tree[u].child.push_back(v);
    build_tree(v, w, u);
  }
}
int find_non_one(int u) {
  if (tree[u].non_one != -1) {
    return tree[u].non_one;
  }
  if (tree[u].val != 1) {
    return tree[u].non_one = u;
  } else {
    return tree[u].non_one = find_non_one(tree[u].fa);
  }
}
void init() {
  for (int i = 1; i <= n; i++) {
    edge[i].clear();
    tree[i].fa = tree[i].val = tree[i].non_one = -1;
    tree[i].child.clear();
  }
  edge_ord.clear();
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    long long p;
    scanf("%d %d %lld", &x, &y, &p);
    edge[x].push_back(make_pair(y, p));
    edge[y].push_back(make_pair(x, p));
    edge_ord.push_back(make_pair(x, y));
  }
  build_tree(1, 1, -1);
  tree[1].non_one = 1;
  for (int i = 1; i <= n; i++) {
    find_non_one(i);
  }
}
void update(long long p, long long c) {
  pair<long long, long long> e = edge_ord[p];
  int u = e.first, v = e.second;
  if (tree[v].fa == u) {
    swap(u, v);
  }
  tree[u].val = c;
  if (c == 1) {
    tree[u].non_one = tree[v].non_one;
  }
}
vector<pair<long long, long long> > getPath(int u) {
  int num = 70;
  vector<pair<long long, long long> > ret;
  while (num-- && u > 1) {
    vector<long long> ones;
    while (true) {
      if (u == 1 || tree[u].val != 1) {
        break;
      }
      ones.push_back(u);
      u = tree[u].non_one;
    }
    for (int i = 0; i < ones.size(); i++) {
      int v = ones[i];
      tree[v].non_one = u;
    }
    ret.push_back(make_pair(u, tree[u].val));
    u = tree[u].fa;
  }
  return ret;
}
void print(vector<pair<long long, long long> > v) {
  printf("Printing\n");
  for (int i = 0; i < v.size(); i++) {
    cout << v[i].first << " " << v[i].second << endl;
  }
}
int getInter(vector<pair<long long, long long> > x,
             vector<pair<long long, long long> > y) {
  for (int i = 0; i < x.size(); i++) {
    int xP = x[i].first;
    for (int j = 0; j < y.size(); j++) {
      int yP = y[j].first;
      if (xP == yP) {
        return xP;
      }
    }
  }
  return -1;
}
long long getAns(long long x, long long y, long long val) {
  vector<pair<long long, long long> > xPath = getPath(x);
  vector<pair<long long, long long> > yPath = getPath(y);
  int inter = getInter(xPath, yPath);
  for (int i = 0; i < xPath.size(); i++) {
    int p = xPath[i].first;
    long long num = xPath[i].second;
    if (p == inter) {
      break;
    }
    val /= num;
    if (val == 0) {
      break;
    }
  }
  for (int i = 0; i < yPath.size(); i++) {
    int p = yPath[i].first;
    long long num = yPath[i].second;
    if (p == inter) {
      break;
    }
    val /= num;
    if (val == 0) {
      break;
    }
  }
  return val;
}
void solve() {
  for (int i = 0; i < m; i++) {
    long long o, a, b;
    scanf("%lld %lld %lld", &o, &a, &b);
    if (o == 1) {
      long long y;
      scanf("%lld", &y);
      printf("%lld\n", getAns(a, b, y));
    } else {
      update(a - 1, b);
    }
  }
}
int main() {
  while (cin >> n >> m) {
    init();
    solve();
  }
}
