#include <bits/stdc++.h>
using namespace std;
const int IT_MAX = 1 << 20;
const int INF = -1;
long long bit[IT_MAX + 10];
void update(int p, long long dv) {
  for (; p <= IT_MAX; p += p & (-p)) bit[p] += dv;
}
long long query(int p) {
  long long rv = 0;
  for (; p; p -= p & (-p)) rv += bit[p];
  return rv;
}
int lf[600010], rg[600010], ti, lev[600010];
vector<int> mat[600010];
vector<pair<int, int> > quer[600010], del[600010];
queue<int> que;
long long prin[600010];
void dfs(int p, int pa) {
  lf[p] = ++ti;
  for (auto x : mat[p]) {
    if (x == pa) continue;
    dfs(x, p);
  }
  rg[p] = ++ti;
}
void bfs(int p) {
  que.push(p);
  lev[p] = 1;
  while (!que.empty()) {
    p = que.front();
    que.pop();
    for (auto x : quer[p]) {
      update(lf[p], x.second);
      update(rg[p], -x.second);
      if (lev[p] + x.first + 1 < IT_MAX)
        del[lev[p] + x.first + 1].push_back(make_pair(p, -x.second));
    }
    for (auto x : mat[p]) {
      if (lev[x]) continue;
      lev[x] = lev[p] + 1;
      que.push(x);
    }
    for (auto x : del[lev[p]]) {
      update(lf[x.first], x.second);
      update(rg[x.first], -x.second);
    }
    del[lev[p]].clear();
    prin[p] = query(lf[p]);
  }
}
int main() {
  ios::sync_with_stdio(false);
  int n, u, v, c, q;
  cin >> n;
  for (int i = 1; i <= n - 1; i++) {
    cin >> u >> v;
    mat[u].push_back(v);
    mat[v].push_back(u);
  }
  cin >> q;
  for (int i = 1; i <= q; i++) {
    cin >> u >> v >> c;
    quer[u].push_back(make_pair(v, c));
  }
  dfs(1, 1);
  bfs(1);
  for (int i = 1; i <= n; i++) cout << prin[i] << ' ';
  return 0;
}
