#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long int INFL = 0x3f3f3f3f3f3f3f3f;
const double pi = atan(1.0) * 4.0;
const int N = 3e5 + 500;
long long int st[4 * N], v[N];
long long int build(long long int st[], long long int v[], int idx, int l,
                    int r) {
  if (l == r) return st[idx] = v[l];
  int m = (l + r) / 2;
  int lc = 2 * idx + 1;
  int rc = 2 * idx + 2;
  return st[idx] = build(st, v, lc, l, m) + build(st, v, rc, m + 1, r);
}
void update(long long int st[], long long int v[], int idx, int i,
            long long int val, int l, int r) {
  if (l == r) {
    st[idx] = v[l] = val;
    return;
  }
  int m = (l + r) / 2;
  int lc = 2 * idx + 1;
  int rc = 2 * idx + 2;
  if (i <= m)
    update(st, v, lc, i, val, l, m);
  else
    update(st, v, rc, i, val, m + 1, r);
  st[idx] = st[lc] + st[rc];
}
long long int query(long long int st[], int idx, int l, int r, long long int a,
                    long long int b) {
  if (a == l and b == r) return st[idx];
  int m = (l + r) / 2;
  int lc = 2 * idx + 1;
  int rc = 2 * idx + 2;
  if (b <= m)
    return query(st, lc, l, m, a, b);
  else if (a > m)
    return query(st, rc, m + 1, r, a, b);
  else
    return query(st, lc, l, m, a, m) + query(st, rc, m + 1, r, m + 1, b);
}
long long int n;
vector<long long int> g[N];
vector<pair<long long int, long long int> > ac[N];
long long int ans[N];
void dfs(int a, int dad, int d) {
  for (int i = 0; i < ac[a].size(); i++) {
    int pos = min(n - 1, d + ac[a][i].first);
    update(st, v, 0, pos, v[pos] + ac[a][i].second, 0, n - 1);
  }
  for (int i = 0; i < g[a].size(); i++) {
    if (g[a][i] != dad) dfs(g[a][i], a, d + 1);
  }
  ans[a] = query(st, 0, 0, n - 1, d, n - 1);
  for (int i = 0; i < ac[a].size(); i++) {
    int pos = min(n - 1, d + ac[a][i].first);
    update(st, v, 0, pos, v[pos] - ac[a][i].second, 0, n - 1);
  }
}
int main(void) {
  ios_base::sync_with_stdio(false);
  long long int a, b, c;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    cin >> a >> b;
    g[a - 1].push_back(b - 1);
    g[b - 1].push_back(a - 1);
  }
  for (int i = 0; i < N; i++) v[i] = 0;
  build(st, v, 0, 0, n - 1);
  int m;
  cin >> m;
  while (m--) {
    cin >> a >> b >> c;
    ac[a - 1].push_back(make_pair(b, c));
  }
  dfs(0, 0, 0);
  for (int i = 0; i < n; i++) cout << ans[i] << (i == n - 1 ? '\n' : ' ');
  return 0;
}
