#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int maxn = 8e5 + 5;
const double eps = 1e-12;
const int inf = 0x3f3f3f3f;
map<int, int>::iterator it;
struct edge {
  int u, v, ne;
} e[maxn];
int n, m;
int head[maxn], len;
long long w[maxn], ans[maxn];
vector<int> d[maxn];
vector<long long> c[maxn];
void add(int u, int v) {
  e[len].u = u;
  e[len].v = v;
  e[len].ne = head[u];
  head[u] = len++;
}
void dfs(int x, int p, int deep, long long val) {
  ans[x] = val - w[deep];
  for (int i = 0; i < d[x].size(); i++) {
    ans[x] += c[x][i];
    d[x][i] = min(n, d[x][i]);
    w[deep + d[x][i] + 1] += c[x][i];
  }
  for (int i = head[x]; i != -1; i = e[i].ne) {
    if (e[i].v == p) continue;
    dfs(e[i].v, x, deep + 1, ans[x]);
  }
  for (int i = 0; i < d[x].size(); i++) w[deep + d[x][i] + 1] -= c[x][i];
  return;
}
int main() {
  memset(head, -1, sizeof(head));
  cin >> n;
  for (int i = 1, x, y; i < n; i++) {
    scanf("%d %d", &x, &y);
    add(x, y);
    add(y, x);
  }
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    int x, y;
    long long v;
    scanf("%d %d %lld", &x, &y, &v);
    d[x].push_back(y);
    c[x].push_back(v);
  }
  dfs(1, 0, 1, 0);
  for (int i = 1; i <= n; i++) printf("%lld ", ans[i]);
  return 0;
}
