#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000010;
int dep[maxn], N, Laxt[maxn], Next[maxn], To[maxn], cnt;
int laxt2[maxn], next2[maxn], D[maxn], X[maxn], tot;
long long ans[maxn];
void add(int u, int v) {
  Next[++cnt] = Laxt[u];
  Laxt[u] = cnt;
  To[cnt] = v;
}
void add2(int u, int d, int x) {
  next2[++tot] = laxt2[u];
  laxt2[u] = tot;
  D[tot] = d;
  X[tot] = x;
}
void dfs(int u, int f, long long sum, long long mp[]) {
  dep[u] = dep[f] + 1;
  sum -= mp[dep[u]];
  for (int i = laxt2[u]; i; i = next2[i]) {
    sum += X[i];
    if (dep[u] + D[i] + 1 <= N) mp[dep[u] + D[i] + 1] += X[i];
  }
  ans[u] = sum;
  for (int i = Laxt[u]; i; i = Next[i])
    if (To[i] != f) dfs(To[i], u, sum, mp);
  for (int i = laxt2[u]; i; i = next2[i]) {
    sum -= X[i];
    if (dep[u] + D[i] + 1 <= N) mp[dep[u] + D[i] + 1] -= X[i];
  }
}
long long mp[maxn];
int main() {
  int u, v, x, Q;
  scanf("%d", &N);
  for (int i = 1; i <= N - 1; i++) {
    scanf("%d%d", &u, &v);
    add(u, v);
    add(v, u);
  }
  scanf("%d", &Q);
  for (int i = 1; i <= Q; i++) {
    scanf("%d%d%d", &u, &v, &x);
    add2(u, v, x);
  }
  dfs(1, 0, 0LL, mp);
  for (int i = 1; i <= N; i++) printf("%lld ", ans[i]);
  return 0;
}
