#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void read(T &x) {
  x = 0;
  bool f = false;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = true;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 3) + (x << 1) + ch - '0';
    ch = getchar();
  }
  x = f ? -x : x;
}
vector<int> h[300005];
vector<pair<int, int> > g[300005];
int n, m;
long long b[300005], ans[300005];
inline void dfs(int rt, int fa, int dep, long long sum) {
  for (int i = 0; i < (int)g[rt].size(); ++i) {
    int d = g[rt][i].first, x = g[rt][i].second;
    b[dep] += x, b[min(n + 1, dep + d + 1)] -= x;
  }
  ans[rt] = sum += b[dep];
  for (int i = 0; i < (int)h[rt].size(); ++i) {
    int x = h[rt][i];
    if (x == fa) continue;
    dfs(x, rt, dep + 1, sum);
  }
  for (int i = 0; i < (int)g[rt].size(); ++i) {
    int d = g[rt][i].first, x = g[rt][i].second;
    b[dep] -= x, b[min(n + 1, dep + d + 1)] += x;
  }
}
int main() {
  read(n);
  int u, v;
  for (int i = 1; i < n; ++i) {
    read(u), read(v);
    h[u].push_back(v), h[v].push_back(u);
  }
  read(m);
  int x, y, z;
  for (int i = 1; i <= m; ++i) {
    read(x), read(y), read(z);
    g[x].push_back(make_pair(y, z));
  }
  dfs(1, 0, 0, 0);
  for (int i = 1; i <= n; ++i) printf("%lld ", ans[i]);
  return 0;
}
