#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> adj[300005];
vector<pair<int, int>> ops[300005];
int64_t tag[600005], ans[600005];
long long cur;
void dfs(int u, int p, int depth) {
  for (auto p : ops[u]) {
    int val, dep;
    tie(val, dep) = p;
    cur += val;
    tag[depth + dep] += val;
  }
  ans[u] = cur;
  cur -= tag[depth];
  for (int v : adj[u])
    if (v != p) dfs(v, u, depth + 1);
  cur += tag[depth];
  for (auto p : ops[u]) {
    int val, dep;
    tie(val, dep) = p;
    cur -= val;
    tag[depth + dep] -= val;
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < (n - 1); i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  scanf("%d", &m);
  for (int i = 0; i < (m); i++) {
    int v, d, x;
    scanf("%d%d%d", &v, &d, &x);
    d = min(d, n + 1);
    ops[v].emplace_back(x, d);
  }
  dfs(1, 0, 1);
  for (int i = 1; i <= (n); i++) printf("%" PRId64 " ", ans[i]);
  return 0;
}
