func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 7;   vector<pair<int, int> > v[N];   int n, m;   int foo, bar, id;   long long val[N];   long long wt[N];   int dep[N];   int dp[20][N];   int par[N];   int x1[N];   int x2[N];   void dfs(int node, int baap) {     dep[node] = dep[baap] + 1;     dp[0][node] = baap;     par[node] = baap;     for (int i = 0; i < v[node].size(); i++) {       int beta = v[node][i].first;       int mark = v[node][i].second;       if (beta == baap) continue;       val[beta] = wt[mark];       dfs(beta, node);     }   }   int jump(int p, int dist) {     for (int i = 19; i >= 0; i--) {       if ((1 << i) <= dist) {         dist -= 1 << i;         p = dp[i][p];       }     }     return p;   }   int lca(int p, int q) {     if (dep[p] < dep[q]) swap(p, q);     p = jump(p, dep[p] - dep[q]);     if (p == q) return p;     for (int i = 19; i >= 0; i--) {       int pp = dp[i][p];       int qq = dp[i][q];       if (pp != qq) p = pp, q = qq;     }     return dp[0][p];   }   int find(int p) {     if (val[p] > 1) return p;     return par[p] = find(par[p]);   }   int main() {     cin >> n >> m;     for (int i = 1; i < n; i++) {       scanf( %d%d%lld , &foo, &bar, &wt[i]);       v[foo].push_back(make_pair(bar, i));       v[bar].push_back(make_pair(foo, i));       x1[i] = foo;       x2[i] = bar;     }     val[1] = 2;     dfs(1, 0);     for (int j = 1; j < 20; j++) {       for (int i = 1; i <= n; i++) {         dp[j][i] = dp[j - 1][dp[j - 1][i]];       }     }     while (m--) {       int p, q, tp;       long long r;       scanf( %d , &id);       if (id == 1) {         scanf( %d%d%lld , &p, &q, &r);         int lc = lca(p, q);         tp = p;         while (r and dep[tp] > dep[lc]) {           r /= val[tp];           tp = find(par[tp]);         }         tp = q;         while (r and dep[tp] > dep[lc]) {           r /= val[tp];           tp = find(par[tp]);         }         printf( %lld n , r);       } else {         scanf( %d%lld , &p, &r);         wt[p] = r;         if (x2[p] == dp[0][x1[p]]) swap(x1[p], x2[p]);         val[x2[p]] = r;       }     }     return 0;   }   