#include <bits/stdc++.h>
using namespace std;
vector<int> h[300010];
vector<pair<int, int> > g[300010];
int n, m;
long long b[300010], ans[300010];
void ae(int x, int y) { h[x].push_back(y); }
void dfs(int u, int fa, int dep, long long sum) {
  for (int i = 0; i < g[u].size(); i++) {
    int d = g[u][i].first, x = g[u][i].second;
    b[dep] += x;
    b[min(n + 1, dep + d + 1)] -= x;
  }
  sum += b[dep];
  ans[u] = sum;
  for (int i = 0; i < h[u].size(); i++) {
    int v = h[u][i];
    if (v == fa) continue;
    dfs(v, u, dep + 1, sum);
  }
  for (int i = 0; i < g[u].size(); i++) {
    int d = g[u][i].first, x = g[u][i].second;
    b[dep] -= x;
    b[min(n + 1, dep + d + 1)] += x;
  }
}
int main() {
  scanf("%d", &n);
  int x, y, z;
  for (int i = 1; i < n; i++) {
    scanf("%d%d", &x, &y);
    ae(x, y);
    ae(y, x);
  }
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%d", &x, &y, &z);
    g[x].push_back(make_pair(y, z));
  }
  dfs(1, 0, 0, 0);
  for (int i = 1; i <= n; i++) printf("%I64d%c", ans[i], (i == n) ? '\n' : ' ');
  return 0;
}
