#include <bits/stdc++.h>
using namespace std;
long long ar[400001];
long long ans[300001];
vector<pair<int, int> > v2[300001];
vector<int> v[300001];
void dfs(int i, int p, int d, long long ct) {
  int j;
  for (j = 0; j < v2[i].size(); ++j) {
    if (d + v2[i][j].first + 1 <= 400000) {
      ar[d + v2[i][j].first + 1] -= v2[i][j].second;
    }
    ct = ct + v2[i][j].second;
  }
  ct = ct + ar[d];
  ans[i] = ct;
  for (j = 0; j < v[i].size(); ++j) {
    if (v[i][j] != p) dfs(v[i][j], i, d + 1, ct);
  }
  for (j = 0; j < v2[i].size(); ++j) {
    if (d + v2[i][j].first + 1 <= 400000) {
      ar[d + v2[i][j].first + 1] += v2[i][j].second;
    }
    ct = ct - v2[i][j].second;
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  int T;
  T = 1;
  while (T--) {
    int n, i, j, a, b, q, c;
    cin >> n;
    for (i = 0; i < n - 1; ++i) {
      cin >> a >> b;
      v[a].push_back(b);
      v[b].push_back(a);
    }
    cin >> q;
    while (q > 0) {
      cin >> a >> b >> c;
      v2[a].push_back({b, c});
      --q;
    }
    dfs(1, -1, 1, 0);
    for (i = 1; i <= n; ++i) cout << ans[i] << " ";
    cout << endl;
  }
  return 0;
}
