#include <bits/stdc++.h>
using namespace std;
long long n, m;
long long fen[1000005], ans[1000005];
vector<long long> g[1000005];
vector<pair<int, long long> > a[1000005];
void up(long long x, long long y) {
  for (; x <= n + 2; x += x & -x) fen[x] += y;
}
long long qu(long long x) {
  long long top = 0;
  for (; x > 0; x -= x & -x) top += fen[x];
  return top;
}
void dfs(long long node, long long par, long long der) {
  for (long long i = 0; i < a[node].size(); i++) {
    up(der, a[node][i].second);
    up(min(n + 1, der + a[node][i].first + 1), -a[node][i].second);
  }
  ans[node] = qu(der);
  for (long long i = 0; i < g[node].size(); i++)
    if (g[node][i] != par) dfs(g[node][i], node, der + 1);
  for (long long i = 0; i < a[node].size(); i++) {
    up(der, -a[node][i].second);
    up(min(n + 1, der + a[node][i].first + 1), +a[node][i].second);
  }
}
int main() {
  scanf("%lld", &n);
  for (long long i = 1; i < n; i++) {
    long long u, v;
    scanf("%lld %lld", &u, &v);
    g[u].push_back(v);
    g[v].push_back(u);
  }
  scanf("%lld", &m);
  for (long long i = 1; i <= m; i++) {
    long long x, y, z;
    scanf("%lld %lld %lld", &x, &y, &z);
    a[x].push_back(make_pair(y, z));
  }
  dfs(1, 0, 1);
  for (long long i = 1; i <= n; i++) printf("%lld ", ans[i]);
  return 0;
}
