#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 5;
const int MAXM = 4e7 + 5;
const int MOD = 1e9 + 7;
long long sum[MAXN];
void add(long long x, long long y) {
  for (; x < MAXN; x += x & -x) sum[x] += y;
}
long long query(long long x) {
  long long ans = 0;
  for (; x; x -= x & -x) {
    ans += sum[x];
  }
  return ans;
}
int n, m, x, y, a, b, c;
vector<int> v[MAXN];
long long ans[MAXN];
struct node {
  int d, x;
} p;
vector<node> g[MAXN];
void dfs(int u, int fa, int dep, long long s) {
  int len = g[u].size();
  for (int i = 0; i <= len - 1; i++) {
    p = g[u][i];
    sum[dep] += p.x;
    sum[dep + p.d + 1] -= p.x;
  }
  s = s + sum[dep];
  ans[u] = s;
  int len2 = v[u].size();
  for (int i = 0; i <= len2 - 1; i++) {
    int y = v[u][i];
    if (y == fa) continue;
    dfs(y, u, dep + 1, s);
  }
  for (int i = 0; i <= len - 1; i++) {
    p = g[u][i];
    sum[dep] -= p.x;
    sum[dep + p.d + 1] += p.x;
  }
}
int main() {
  while (~scanf("%d", &n)) {
    memset(sum, 0, sizeof(sum));
    for (int i = 1; i <= n; i++) v[i].clear(), g[i].clear();
    for (int i = 1; i <= n - 1; i++) {
      scanf("%d%d", &x, &y);
      v[x].push_back(y);
      v[y].push_back(x);
    }
    scanf("%d", &m);
    for (int i = 1; i <= m; i++) {
      scanf("%d%d%d", &a, &b, &c);
      p.d = b, p.x = c;
      p.d = min(p.d, n);
      g[a].push_back(p);
    }
    dfs(1, -1, 1, 0);
    for (int i = 1; i <= n; i++) {
      printf("%I64d ", ans[i]);
    }
    printf("\n");
  }
}
