#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char s;
  while ((s = getchar()) < '0' || s > '9')
    if (s == '-') f = -1;
  while (s >= '0' && s <= '9')
    x = (x << 3) + (x << 1) + (s ^ '0'), s = getchar();
  return x * f;
}
const int maxn = 600005;
int n, m, head[maxn], tot;
struct node {
  int to, nxt;
} e[maxn * 2];
struct Q {
  int v, d;
  long long x;
} p[maxn];
vector<int> q[maxn];
inline void add(int u, int v) {
  e[++tot].to = v, e[tot].nxt = head[u], head[u] = tot;
  e[++tot].to = u, e[tot].nxt = head[v], head[v] = tot;
}
long long h[maxn];
int high[maxn];
long long ans[maxn];
void dfs(int u, int fap, long long pre) {
  high[u] = high[fap] + 1;
  for (auto num : q[u]) {
    h[high[u]] += p[num].x;
    if (p[num].d <= n) h[high[u] + p[num].d] -= p[num].x;
  }
  pre += h[high[u]];
  ans[u] = pre;
  for (register int i = head[u]; i; i = e[i].nxt) {
    int v = e[i].to;
    if (v == fap) continue;
    dfs(v, u, pre);
  }
  for (auto num : q[u]) {
    h[high[u]] -= p[num].x;
    if (p[num].d <= n) h[high[u] + p[num].d] += p[num].x;
  }
}
int main() {
  high[0] = 1;
  n = read();
  for (int i = 1; i < n; ++i) {
    int u = read(), v = read();
    add(u, v);
  }
  m = read();
  for (register int i = 1; i <= m; ++i) {
    p[i].v = read(), p[i].d = read() + 1, p[i].x = read();
    q[p[i].v].push_back(i);
  }
  dfs(1, 0, 0ll);
  for (register int i = 1; i <= n; ++i) printf("%lld ", ans[i]);
  return 0;
}
