#include <bits/stdc++.h>
using namespace std;
long long f[4 * 300005], yc[4 * 300005], ff[300005];
struct ss {
  int d;
  long long v;
};
vector<ss> G[300005];
struct s {
  int next, to;
} edge[2 * 300005];
int tot, head[300005];
void add(int x, int y) {
  edge[tot].next = head[x];
  edge[tot].to = y;
  head[x] = tot++;
}
void up(int rt) {
  if (yc[rt]) {
    f[rt << 1] += yc[rt];
    f[rt << 1 | 1] += yc[rt];
    yc[rt << 1] += yc[rt];
    yc[rt << 1 | 1] += yc[rt];
    yc[rt] = 0;
  }
}
void update(int rt, int L, int R, int l, int r, long long v) {
  if (l <= L && R <= r) {
    f[rt] += v;
    yc[rt] += v;
    return;
  }
  up(rt);
  int mid = (L + R) / 2;
  if (l <= mid) update(rt << 1, L, mid, l, r, v);
  if (r >= mid + 1) update(rt << 1 | 1, mid + 1, R, l, r, v);
}
long long query(int rt, int L, int R, int whe) {
  if (L == R) return f[rt];
  up(rt);
  int mid = (L + R) / 2;
  if (whe <= mid)
    return query(rt << 1, L, mid, whe);
  else
    return query(rt << 1 | 1, mid + 1, R, whe);
}
int n;
void dfs(int x, int dep, int pre) {
  ss z;
  for (int i = 0; i < G[x].size(); ++i) {
    z = G[x][i];
    update(1, 1, n, dep, min(n, dep + z.d), z.v);
  }
  ff[x] = query(1, 1, n, dep);
  for (int i = head[x]; i != -1; i = edge[i].next)
    if (edge[i].to != pre) dfs(edge[i].to, dep + 1, x);
  for (int i = 0; i < G[x].size(); ++i) {
    z = G[x][i];
    update(1, 1, n, dep, min(n, dep + z.d), -z.v);
  }
}
int main() {
  scanf("%d", &n);
  memset(head, -1, sizeof(head));
  tot = 0;
  int x, y;
  for (int i = 1; i < n; i++) {
    scanf("%d %d", &x, &y);
    add(x, y);
    add(y, x);
  }
  for (int i = 1; i <= n; i++) G[i].clear();
  int m;
  scanf("%d", &m);
  ss z;
  for (int i = 1; i <= m; ++i) {
    scanf("%d %d %I64d", &x, &z.d, &z.v);
    G[x].push_back(z);
  }
  memset(yc, 0, sizeof(yc));
  memset(f, 0, sizeof(f));
  memset(ff, 0, sizeof(ff));
  dfs(1, 1, -1);
  for (int i = 1; i <= n; i++) printf("%I64d%c", ff[i], i == n ? '\n' : ' ');
}
