#include <bits/stdc++.h>
using namespace std;
long long tree[4000000];
void upd(int x, int l, int r, int v, int val) {
  if (l == r)
    tree[x] += val;
  else {
    if (v <= (l + r) / 2)
      upd((x << 1), l, (l + r) / 2, v, val);
    else
      upd(((x << 1) + 1), (l + r) / 2 + 1, r, v, val);
    tree[x] = tree[(x << 1)] + tree[((x << 1) + 1)];
  }
}
long long Q(int x, int l, int r, int s, int e) {
  if (l > e || r < s) return 0;
  if (l >= s && r <= e) return tree[x];
  return Q((x << 1), l, (l + r) / 2, s, e) +
         Q(((x << 1) + 1), (l + r) / 2 + 1, r, s, e);
}
vector<int> adj[1000000];
vector<pair<int, int> > q[1000000];
long long val[1000000];
int n;
void dfs(int v, int p, int lev) {
  for (auto x : q[v]) {
    upd(1, 0, 2 * n, lev, x.second);
    upd(1, 0, 2 * n, lev + x.first + 1, -x.second);
  }
  val[v] = Q(1, 0, 2 * n, 0, lev);
  for (auto u : adj[v]) {
    if (u == p) continue;
    dfs(u, v, lev + 1);
  }
  for (auto x : q[v]) {
    upd(1, 0, 2 * n, lev, -x.second);
    upd(1, 0, 2 * n, lev + x.first + 1, x.second);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i < n; i++) {
    int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  int m;
  cin >> m;
  while (m--) {
    int v, d, x;
    cin >> v >> d >> x;
    q[v].push_back({d, x});
  }
  dfs(1, -1, 0);
  for (int i = 1; i <= n; i++) cout << val[i] << ' ';
}
