#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
struct A {
  int dep, val;
} dl[N];
struct B {
  int to, nxt;
} e[N << 1];
int cnt, n, q, hd[N];
long long ans[N];
void add(int u, int v) { e[++cnt] = (B){v, hd[u]}, hd[u] = cnt; }
vector<A> que[N];
void dfs(int u, int fa, long long sum) {
  sum += dl[dl[u].dep].val;
  for (int i = 0; i < que[u].size(); i++) {
    sum += que[u][i].val;
    if (dl[u].dep + que[u][i].dep + 1 <= n)
      dl[dl[u].dep + que[u][i].dep + 1].val -= que[u][i].val;
  }
  ans[u] = sum;
  for (int i = hd[u]; i; i = e[i].nxt) {
    int v = e[i].to;
    if (v == fa) continue;
    dl[v].dep = dl[u].dep + 1;
    dfs(v, u, sum);
  }
  for (int i = 0; i < que[u].size(); i++)
    if (dl[u].dep + que[u][i].dep + 1 <= n)
      dl[dl[u].dep + que[u][i].dep + 1].val += que[u][i].val;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    add(u, v);
    add(v, u);
  }
  scanf("%d", &q);
  for (int i = 1; i <= q; i++) {
    int v, d, x;
    scanf("%d%d%d", &v, &d, &x);
    que[v].push_back((A){d, x});
  }
  dl[1].dep = 1;
  dfs(1, -1, 0);
  for (int i = 1; i <= n; i++) printf("%lld ", ans[i]);
  return 0;
}
