#include <bits/stdc++.h>
using namespace std;
map<long long, long long> dp;
long long re[3 * 100009];
vector<pair<long long, long long>> tree[3 * 100009];
vector<long long> v[3 * 100009];
void dfs(long long x, long long p, long long lev, long long val) {
  for (auto pp : tree[x]) {
    dp[lev] += pp.second;
    dp[pp.first + 1 + lev] -= pp.second;
  }
  re[x] = dp[lev] + val;
  for (auto pp : v[x]) {
    if (pp != p) {
      dfs(pp, x, lev + 1, val + dp[lev]);
    }
  }
  for (auto pp : tree[x]) {
    dp[lev] -= pp.second;
    dp[pp.first + 1 + lev] += pp.second;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n;
  long long x, y;
  cin >> n;
  for (long long i = 0; i < n - 1; i++) {
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  long long q, z;
  cin >> q;
  while (q--) {
    cin >> x >> y >> z;
    tree[x].push_back({y, z});
  }
  dfs(1, 0, 1, 0);
  for (long long i = 1; i < n + 1; i++) {
    cout << re[i] << " ";
  }
}
