#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3f;
const int MOD1 = 1e9 + 7, MOD2 = 1e9 + 9;
const int N = 3e5 + 10;
int n, m, u, v, d, x;
vector<pair<int, int> > upd[N];
long long bit[N], ans[N];
vector<int> adj[N];
void add(int p, int v) {
  p++;
  for (; p < N; p += p & -p) bit[p] += (long long)v;
}
long long get(int p) {
  p++;
  long long r = 0LL;
  for (; p > 0; p -= p & -p) r += bit[p];
  return r;
}
void dfs(int v, int p, int d) {
  for (auto &u : upd[v]) {
    int k = min(N, d + u.first + 1);
    add(d, u.second), add(k, -u.second);
  }
  ans[v] = get(d);
  for (auto &u : adj[v])
    if (u != p) dfs(u, v, d + 1);
  for (auto &u : upd[v]) {
    int k = min(N, d + u.first + 1);
    add(d, -u.second), add(k, u.second);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n - 1; i++) {
    scanf("%d%d", &u, &v);
    adj[u].push_back(v), adj[v].push_back(u);
  }
  for (scanf("%d", &m); m--;) {
    scanf("%d%d%d", &v, &d, &x);
    upd[v].push_back(pair<int, int>(d, x));
  }
  dfs(1, 0, 0);
  for (int i = 1; i <= n; i++) printf("%lld ", ans[i]);
}
