#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
vector<int> g[2 * N];
vector<pair<int, int> > mark[N];
int n, m;
long long val[N];
struct Bit {
  long long c[N];
  int lowbit(int x) { return x & -x; }
  long long Sum(int x) {
    long long res = 0;
    while (x > 0) {
      res += c[x];
      x -= lowbit(x);
    }
    return res;
  }
  void Add(int x, int d) {
    while (x <= n) {
      c[x] += d;
      x += lowbit(x);
    }
  }
} b;
void dfs(int u, int fa, int dep) {
  for (auto it : mark[u]) {
    b.Add(max(n - dep - it.first, 1), it.second);
  }
  val[u] = b.Sum(max(n - dep, 1));
  for (auto v : g[u]) {
    if (v == fa) continue;
    dfs(v, u, dep + 1);
  }
  for (auto it : mark[u]) {
    b.Add(max(n - dep - it.first, 1), -it.second);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    g[x].push_back(y);
    g[y].push_back(x);
  }
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    int u, d, x;
    scanf("%d %d %d", &u, &d, &x);
    mark[u].push_back({d, x});
  }
  dfs(1, 0, 0);
  for (int i = 1; i <= n; i++) {
    printf("%lld ", val[i]);
  }
}
