#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const double PI = acos(-1);
int n, i, j, k, t;
int m;
vector<int> adj[300002];
vector<pair<int, int> > q[300002];
long long tree[1200005];
long long ans[300002];
void build() { memset(tree, 0, sizeof tree); }
void update(int l, int r, int pos, int ql, int qr, int d) {
  if (l > qr || r < ql) return;
  if (l >= ql && r <= qr) {
    tree[pos] += d;
    return;
  }
  if (tree[pos]) {
    tree[2 * pos + 1] += tree[pos];
    tree[2 * pos + 2] += tree[pos];
    tree[pos] = 0;
  }
  int mid = (l + r) / 2;
  update(l, mid, 2 * pos + 1, ql, qr, d);
  update(mid + 1, r, 2 * pos + 2, ql, qr, d);
}
long long query(int l, int r, int pos, int idx) {
  if (l == r) return tree[pos];
  if (tree[pos]) {
    tree[2 * pos + 1] += tree[pos];
    tree[2 * pos + 2] += tree[pos];
    tree[pos] = 0;
  }
  int mid = (l + r) / 2;
  if (mid >= idx)
    return query(l, mid, 2 * pos + 1, idx);
  else
    return query(mid + 1, r, 2 * pos + 2, idx);
}
void dfs(int v, int p, int d) {
  for (pair<int, int> x : q[v]) {
    update(0, n - 1, 0, d, min(n - 1, d + x.first), x.second);
  }
  ans[v] = query(0, n - 1, 0, d);
  for (int x : adj[v]) {
    if (x == p) continue;
    dfs(x, v, d + 1);
  }
  for (pair<int, int> x : q[v]) {
    update(0, n - 1, 0, d, min(n - 1, d + x.first), -x.second);
  }
}
int main() {
  scanf("%d", &n);
  for (i = 1; i < n; ++i) {
    int a, b;
    scanf("%d %d", &a, &b);
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  scanf("%d", &m);
  for (i = 0; i < m; ++i) {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    q[a].push_back({b, c});
  }
  build();
  dfs(1, 1, 0);
  for (i = 1; i <= n; ++i) printf("%lld ", ans[i]);
  puts("");
  return 0;
}
