#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 7;
vector<pair<long long, long long> > val[N];
vector<long long> v[N];
long long n, x, y, u, d, acc;
long long ans[N], dep[N];
map<long long, long long> uno;
void dfs(long long ver, long long par) {
  dep[ver] = dep[par] + 1;
  for (auto it : val[ver]) {
    acc += it.second;
    uno[dep[ver] + it.first + 1] += it.second;
  }
  acc -= uno[dep[ver]];
  ans[ver] = acc;
  for (auto it : v[ver]) {
    if (it == par) continue;
    dfs(it, ver);
  }
  for (auto it : val[ver]) {
    acc -= it.second;
    uno[dep[ver] + it.first + 1] -= it.second;
  }
  acc += uno[dep[ver]];
}
int main() {
  std::ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = int(1); i <= int(n - 1); i++) {
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  long long q;
  cin >> q;
  while (q--) {
    cin >> u >> d >> x;
    val[u].push_back({d, x});
  }
  dfs(1, 0);
  for (int i = int(1); i <= int(n); i++) cout << ans[i] << " ";
}
