#include <bits/stdc++.h>
using namespace std;
const double pi = 2 * acos(0.0);
double inff = 1.0 / 0.0;
long long int x, y, n, i, z, j, k, w, u, q, c, t, m;
long long int range[300010], val[300010], v2[300010];
vector<long long int> v[300010];
vector<pair<long long int, long long int> > v1[300010];
void dfs(long long int src, long long int l, long long int sum) {
  v2[src] = 1;
  for (auto a : v1[src]) {
    range[l] += a.second;
    if (l + a.first < 300010) range[l + a.first + 1] -= a.second;
  }
  sum += range[l];
  val[src] += sum;
  for (auto a : v[src]) {
    if (!v2[a]) dfs(a, l + 1, sum);
  }
  for (auto a : v1[src]) {
    range[l] -= a.second;
    if (l + a.first < 300010) range[l + a.first + 1] += a.second;
  }
}
void solve() {
  cin >> n;
  for (i = (int)1; i < (int)n; i++) {
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  cin >> m;
  for (i = (int)1; i < (int)m + 1; i++) {
    cin >> x >> y >> q;
    v1[x].push_back({y, q});
  }
  memset(v2, 0, sizeof v2);
  dfs(1, 0, 0);
  for (i = 1; i <= n; i++) {
    cout << val[i] << " ";
  }
}
int main(void) {
  ios::sync_with_stdio(false), cout.tie(0), cin.tie(0);
  ;
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
