#include <bits/stdc++.h>
using namespace std;
vector<long long> adj[300005];
vector<pair<long long, long long> > ar[300005];
long long n, vis[300005], tree[300005], ans[300005];
long long read(long long i) {
  long long sum = 0;
  while (i > 0) {
    sum += tree[i];
    i -= (i & -i);
  }
  return sum;
}
void update(long long i, long long val) {
  while (i <= n) {
    tree[i] += val;
    i += (i & -i);
  }
}
void F(long long u, long long d, long long s) {
  for (long long i = 0; i < ar[u].size(); i++) {
    update(1, s * ar[u][i].second);
    update(d + ar[u][i].first + 1, -s * ar[u][i].second);
  }
}
void dfs(long long u, long long d) {
  vis[u] = 1;
  F(u, d, 1);
  for (long long i = 0; i < adj[u].size(); i++) {
    long long v = adj[u][i];
    if (!vis[v]) {
      dfs(v, d + 1);
    }
  }
  ans[u] = read(d);
  F(u, d, -1);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long x, y, m, v, d;
  cin >> n;
  for (long long i = 1; i <= n - 1; i++) {
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  cin >> m;
  while (m--) {
    cin >> v >> d >> x;
    ar[v].emplace_back(d, x);
  }
  memset(vis, 0, sizeof vis);
  dfs(1, 1);
  for (long long i = 1; i <= n; i++) {
    cout << ans[i] << " ";
  }
  cout << endl;
  return 0;
}
