#include <bits/stdc++.h>
using namespace std;
const long double EPS = 1e-9;
const long long MOD = 1e9 + 7;
long long tree[700100], res[700100];
vector<int> adj[700100];
vector<pair<long long, long long>> q[700100];
int n;
void update_val(long long val, int i) {
  i += n;
  tree[i] = val;
  for (i >>= 1; i > 0; i >>= 1) tree[i] = tree[i << 1] + tree[i << 1 | 1];
}
long long get_sum(int l, int r) {
  long long res = 0;
  for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
    if (l & 1) res += tree[l++];
    if (r & 1) res += tree[--r];
  }
  return res;
}
void dfs(int u, int pr, long long d) {
  for (auto &p : q[u]) {
    int last = min(n - 1LL, d + p.first);
    update_val(get_sum(last, last + 1) + p.second, last);
  }
  res[u] = get_sum(d, n);
  for (int i : adj[u])
    if (i != pr) {
      dfs(i, u, d + 1);
    }
  for (auto &p : q[u]) {
    int last = min(n - 1LL, d + p.first);
    update_val(get_sum(last, last + 1) - p.second, last);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout << setprecision(20);
  cin >> n;
  for (int i = 1; i < n; i++) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  int m;
  cin >> m;
  while (m-- > 0) {
    long long v, d, x;
    cin >> v >> d >> x;
    v--;
    q[v].push_back({d, x});
  }
  dfs(0, -1, 0);
  for (int i = 0; i < n; i++) cout << res[i] << ' ';
  cout << '\n';
  return 0;
}
