#include <bits/stdc++.h>
using namespace std;
int L, R, aim, n, m, tot, s[300005], dep;
long long t[524288 << 1], ans, op[300005];
vector<pair<int, int> > q[300005];
struct edge {
  int v, n;
} e[300005 << 1];
inline void push(int u, int v) {
  e[++tot] = (edge){v, s[u]};
  s[u] = tot;
}
void change(int k, int l, int r) {
  if (L <= l && r <= R) {
    t[k] += aim;
    return;
  }
  int mid = l + r >> 1;
  if (L <= mid) change(k << 1, l, mid);
  if (mid < R) change(k << 1 | 1, mid + 1, r);
}
void find(int k, int l, int r) {
  ans += t[k];
  if (l == r) return;
  int mid = l + r >> 1;
  if (aim <= mid)
    find(k << 1, l, mid);
  else
    find(k << 1 | 1, mid + 1, r);
}
void dfs(int k, int f) {
  dep++;
  for (auto s : q[k]) {
    L = dep;
    R = dep + s.first;
    aim = s.second;
    change(1, 1, 524288);
  }
  aim = dep;
  ans = 0;
  find(1, 1, 524288);
  op[k] = ans;
  for (int i = s[k]; i; i = e[i].n)
    if (e[i].v != f) dfs(e[i].v, k);
  for (auto s : q[k]) {
    L = dep;
    R = dep + s.first;
    aim = -s.second;
    change(1, 1, 524288);
  }
  dep--;
}
int main() {
  scanf("%d", &n);
  for (int i = 1, u, v; i < n; i++)
    scanf("%d%d", &u, &v), push(u, v), push(v, u);
  scanf("%d", &m);
  for (int v, d, x; m--;) {
    scanf("%d%d%d", &v, &d, &x);
    q[v].push_back(make_pair(d, x));
  }
  dfs(1, 0);
  for (int i = 1; i <= n; i++) printf("%I64d%c", op[i], i == n ? '\n' : ' ');
}
