#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> g(300001);
vector<int> check(300000 + 2, 0);
vector<long long int> ans(300000 + 1, 0);
vector<int> maxm(300001);
vector<pair<int, int>> query[300001];
long long int temp = 0;
int n;
int dfs2(int u, int par) {
  int tem = 0;
  for (auto i : g[u]) {
    if (i == par) {
      continue;
    }
    int te = dfs2(i, u) + 1;
    tem = ((te > tem) ? te : tem);
  }
  return maxm[u] = tem;
}
void dfs(int u, int par, int lvl) {
  long long int ret = temp;
  for (auto i : query[u]) {
    temp += i.second;
    check[lvl + 1 + ((maxm[u] > i.first) ? i.first : maxm[u])] += i.second;
  }
  temp -= check[lvl];
  ans[u] = temp;
  for (auto i : g[u]) {
    if (i == par) {
      continue;
    }
    dfs(i, u, lvl + 1);
  }
  for (auto i : query[u]) {
    check[lvl + 1 + ((maxm[u] > i.first) ? i.first : maxm[u])] -= i.second;
  }
  temp = ret;
}
void solve() {
  int m;
  cin >> n;
  for (int i = 1; i < n; i++) {
    int u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  dfs2(1, 0);
  cin >> m;
  while (m--) {
    int v, d, x;
    cin >> v >> d >> x;
    query[v].push_back({d, x});
  }
  dfs(1, 0, 0);
  for (int i = 1; i <= n; i++) {
    cout << ans[i] << " ";
  }
  cout << "\n";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int test = 1;
  while (test--) {
    solve();
  }
  return 0;
}
