#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 10;
bool visited[maxn] = {};
long long t[maxn] = {}, ans[maxn] = {};
vector<pair<int, int> > q[maxn];
vector<int> adj[maxn];
void dfs(int v, int d, long long c) {
  visited[v] = 1;
  for (auto i : q[v]) {
    t[d] += i.second;
    t[min(d + i.first + 1, maxn - 1)] -= i.second;
  }
  c += t[d];
  ans[v] = c;
  for (auto u : adj[v]) {
    if (visited[u]) continue;
    dfs(u, d + 1, c);
  }
  for (auto i : q[v]) {
    t[d] -= i.second;
    t[min(d + i.first + 1, maxn - 1)] += i.second;
  }
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n, m;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  cin >> m;
  while (m--) {
    int a, b, c;
    cin >> a >> b >> c;
    q[a].push_back({b, c});
  }
  dfs(1, 0, 0);
  for (int i = 1; i <= n; i++) {
    cout << ans[i] << " ";
  }
}
