#include <bits/stdc++.h>
using namespace std;
long long n, m, tot;
long long ans[300005], cha[300005], dep[300005];
long long End[600005], Next[600005], last[300005];
vector<pair<long long, long long> > vec[300005];
void add(long long u, long long v) {
  End[++tot] = v;
  Next[tot] = last[u];
  last[u] = tot;
}
void dfs(long long x, long long fa, long long sum) {
  dep[x] = dep[fa] + 1;
  sum += cha[dep[x]];
  long long len = vec[x].size();
  for (long long i = 0; i < len; i++) {
    sum += vec[x][i].second;
    if (vec[x][i].first + dep[x] + 1ll <= n)
      cha[vec[x][i].first + dep[x] + 1ll] -= vec[x][i].second;
  }
  ans[x] = sum;
  for (long long i = last[x]; i; i = Next[i])
    if (End[i] != fa) dfs(End[i], x, sum);
  for (long long i = 0; i < len; i++)
    if (vec[x][i].first + dep[x] + 1ll <= n)
      cha[vec[x][i].first + dep[x] + 1ll] += vec[x][i].second;
}
signed main() {
  scanf("%lld", &n);
  for (long long i = 1; i < n; i++) {
    long long u, v;
    scanf("%lld %lld", &u, &v);
    add(u, v);
    add(v, u);
  }
  scanf("%d", &m);
  for (long long i = 1; i <= m; i++) {
    long long x, y, z;
    scanf("%lld %lld %lld", &x, &y, &z);
    vec[x].push_back(make_pair(y, z));
  }
  dfs(1, 0, 0);
  for (long long i = 1; i <= n; i++) printf("%lld ", ans[i]);
  return 0;
}
