#include <bits/stdc++.h>
using namespace std;
int n, m, head[300005], idx, dep[300005];
struct edge {
  int v, next;
} e[2 * 300005];
void add(int u, int v) {
  e[++idx].v = v;
  e[idx].next = head[u];
  head[u] = idx;
}
vector<pair<int, int> > v[300005];
long long op[300005];
long long ans[300005];
void dfs(int x, int fa, long long sum) {
  dep[x] = dep[fa] + 1;
  for (int i = 0; i < v[x].size(); i++) {
    pair<int, int> now = v[x][i];
    sum += now.second;
    if (dep[x] + now.first + 1 <= n) op[dep[x] + now.first + 1] -= now.second;
  }
  sum += op[dep[x]];
  ans[x] = sum;
  for (int i = head[x]; i; i = e[i].next) {
    int y = e[i].v;
    if (y == fa) continue;
    dfs(y, x, sum);
  }
  for (int i = 0; i < v[x].size(); i++) {
    pair<int, int> now = v[x][i];
    if (dep[x] + now.first + 1 <= n) op[dep[x] + now.first + 1] += now.second;
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    add(x, y);
    add(y, x);
  }
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    int s, d, x;
    scanf("%d%d%d", &s, &d, &x);
    v[s].push_back(make_pair(d, x));
  }
  dfs(1, 0, 0);
  for (int i = 1; i <= n; i++) cout << ans[i] << ' ';
  return 0;
}
