#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 10;
const int maxm = 1e6 + 10;
const long long mod = 1e9 + 7;
const int inf = 0x3ffffff;
const double eps = 1e-5;
struct Edge {
  int to, next;
} edge[maxn << 1];
int cnt, head[maxn];
void add_edge(int u, int v) {
  edge[++cnt].next = head[u];
  edge[cnt].to = v;
  head[u] = cnt;
}
long long c[maxn], n, m;
void update(int x, long long v) {
  for (int i = x; i <= n; i += (i) & (-i)) c[i] += v;
}
long long getsum(int x) {
  long long sum = 0;
  for (int i = x; i > 0; i -= (i) & (-i)) sum += c[i];
  return sum;
}
vector<long long> val[maxn], D[maxn];
long long ans[maxn];
void dfs(int u, int fa, long long d) {
  for (int i = 0; i < D[u].size(); i++) update(min(n, D[u][i] + d), val[u][i]);
  ans[u] = getsum(n) - getsum(d - 1);
  for (int i = head[u]; i; i = edge[i].next) {
    int v = edge[i].to;
    if (v == fa) continue;
    dfs(v, u, d + 1);
  }
  for (int i = 0; i < D[u].size(); i++) update(min(n, D[u][i] + d), -val[u][i]);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n - 1; i++) {
    int u, v;
    cin >> u >> v;
    add_edge(u, v);
    add_edge(v, u);
  }
  cin >> m;
  for (int i = 1; i <= m; i++) {
    long long u, d, v;
    cin >> u >> d >> v;
    D[u].push_back(d);
    val[u].push_back(v);
  }
  dfs(1, 0, 1);
  for (int i = 1; i <= n; i++) cout << ans[i] << " ";
  return ~~(0 - 0);
}
