func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 3e5 + 50;   long long mod = 998244353;   int n, m, u, v;   vector<int> adj[N];   long long toAdd[N + N];   vector<pair<int, int> > q[N];   long long ans[N];   void dfs(int src, int par, int dep, long long sum) {     for (auto i : q[src]) {       toAdd[dep] += i.second;       toAdd[dep + i.first + 1] -= i.second;     }     sum += toAdd[dep];     ans[src] = sum;     for (auto i : adj[src])       if (i != par) dfs(i, src, dep + 1, sum);     for (auto i : q[src]) {       toAdd[dep] -= i.second;       toAdd[dep + i.first + 1] += i.second;     }   }   int main() {     scanf( %d , &n);     for (int i = 0; i < n - 1; ++i) {       scanf( %d%d , &u, &v);       adj[u].push_back(v);       adj[v].push_back(u);     }     scanf( %d , &m);     int d, x;     while (m--) {       scanf( %d%d%d , &v, &d, &x);       d = min(d, n);       q[v].push_back(make_pair(d, x));     }     dfs(1, 0, 0, 0);     for (int i = 1; i <= n; ++i) printf( %lld  , ans[i]);     return 0;   }   