func_code_string: #include <bits/stdc++.h>   using namespace std;   using ll = long long;   const int N = 3e6 + 44;   const int X[] = {1, 0, -1, 0, 1, -1, 1, -1};   const int Y[] = {0, 1, 0, -1, 1, 1, -1, -1};   const int mod = 998244353;   const int INF = 1e9;   ll ans[N], add[N];   vector<int> g[N];   vector<pair<int, int> > query[N];   void dfs(int v = 0, int p = -1, int h = 0, ll sum = 0) {     for (auto pairr : query[v]) {       int d = pairr.first, x = pairr.second;       add[h] += x;       if (h + d + 1 < N) add[h + d + 1] -= x;     }     sum += add[h];     ans[v] = sum;     for (int to : g[v])       if (to != p) {         dfs(to, v, h + 1, sum);       }     for (auto pairr : query[v]) {       int d = pairr.first, x = pairr.second;       add[h] -= x;       if (h + d + 1 < N) add[h + d + 1] += x;     }   }   int main() {     ios_base::sync_with_stdio(false), cin.tie(NULL);     ;     int n;     cin >> n;     for (int i = 1; i < n; ++i) {       int u, v;       cin >> u >> v;       u--, v--;       g[u].push_back(v);       g[v].push_back(u);     }     int m;     cin >> m;     for (int i = 0; i < m; ++i) {       int v, d, x;       cin >> v >> d >> x;       v--;       query[v].push_back({d, x});     }     dfs();     for (int i = 0; i < n; ++i) cout << ans[i] <<    ;   }   