#include <bits/stdc++.h>
using namespace std;
int n, num[300005], Q;
long long dp[300005], dd[300005];
vector<int> a[300005];
vector<pair<int, int> > b[300005];
void dfs(int h) {
  for (int i = 0; i <= (int)b[h].size() - 1; ++i) {
    dp[h] += b[h][i].second;
    if (num[h] + b[h][i].first + 1 < n + 2)
      dd[num[h] + b[h][i].first + 1] -= b[h][i].second;
  }
  for (int i = 0; i <= (int)a[h].size() - 1; ++i) {
    if (!num[a[h][i]]) {
      num[a[h][i]] = num[h] + 1;
      dp[a[h][i]] = dp[h] + dd[num[a[h][i]]];
      dfs(a[h][i]);
    }
  }
  for (int i = 0; i <= (int)b[h].size() - 1; ++i) {
    if (num[h] + b[h][i].first + 1 < n + 2)
      dd[num[h] + b[h][i].first + 1] += b[h][i].second;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  int u, v, t;
  for (int i = 1; i <= n - 1; ++i) {
    cin >> u >> v;
    a[u].push_back(v);
    a[v].push_back(u);
  }
  cin >> Q;
  for (int i = 1; i <= Q; ++i) {
    cin >> u >> v >> t;
    b[u].push_back(make_pair(v, t));
  }
  num[1] = 1;
  dfs(1);
  for (int i = 1; i <= n; ++i) cout << dp[i] << ' ';
}
