#include <bits/stdc++.h>
using namespace std;
vector<pair<long long int, long long int> > change[300005];
vector<long long int> road[300005];
long long int ans[300005] = {0};
long long int how[1000005] = {0};
bool have[300005] = {0};
void F(long long int now, long long int con, long long int Ans) {
  ans[now] += con;
  long long int N = road[now].size(), M = change[now].size(), i;
  for (i = 0; i < M; i++) {
    how[change[now][i].first + con] += change[now][i].second;
    Ans += change[now][i].second;
  }
  ans[now] = Ans;
  for (i = 0; i < N; i++) {
    if (!have[road[now][i]]) {
      have[road[now][i]] = 1;
      F(road[now][i], con + 1, Ans - how[con]);
    }
  }
  for (i = 0; i < M; i++) {
    how[change[now][i].first + con] -= change[now][i].second;
  }
}
int main() {
  long long int N, M, now = 0, K, t, i, x, y;
  scanf("%lld", &N);
  for (i = 0; i < N - 1; i++) {
    scanf("%lld %lld", &x, &y);
    road[x].push_back(y);
    road[y].push_back(x);
  }
  scanf("%lld", &M);
  for (i = 0; i < M; i++) {
    scanf("%lld %lld %lld", &x, &y, &t);
    change[x].push_back(make_pair(min(y, (long long int)300000), t));
  }
  have[1] = 1;
  F(1, 0, 0);
  for (i = 1; i <= N; i++) printf("%lld ", ans[i]);
  return 0;
}
