#include <bits/stdc++.h>
using namespace std;
long long n, diff[400001], ans[400000];
vector<long long> v[300005];
vector<pair<long long, long long>> q[300005];
void dfs(long long s, long long p, long long h, long long sm) {
  for (auto p : q[s]) {
    long long ra = p.first, val = p.second;
    diff[h] += val;
    if (ra + h + 1 <= 400000) diff[ra + h + 1] -= val;
  }
  sm += diff[h];
  ans[s] = sm;
  for (long long i = 0; i < v[s].size(); i++) {
    if (v[s][i] != p) dfs(v[s][i], s, h + 1, sm);
  }
  for (auto p : q[s]) {
    long long ra = p.first, val = p.second;
    diff[h] -= val;
    if (ra + h + 1 <= 400000) diff[ra + h + 1] += val;
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (long long i = 0; i < n - 1; i++) {
    long long x, y;
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  long long m;
  cin >> m;
  for (long long i = 0; i < m; i++) {
    long long a1, a2, a3;
    cin >> a1 >> a2 >> a3;
    q[a1].push_back({a2, a3});
  }
  dfs(1, -1, 0, 0);
  for (long long i = 1; i < n + 1; i++) cout << ans[i] << " ";
}
