#include <bits/stdc++.h>
#pragma GCC optimize(2)
#pragma GCC optimize("Ofast", "unroll-loops", "omit-frame-pointer", "inline")
using namespace std;
const long long INF = 2e18;
const int maxn = 1e6 + 6;
const int mod = 998244353;
const double eps = 1e-3;
inline bool read(long long &num) {
  char in;
  bool IsN = false;
  in = getchar();
  if (in == EOF) return false;
  while (in != '-' && (in < '0' || in > '9')) in = getchar();
  if (in == '-') {
    IsN = true;
    num = 0;
  } else
    num = in - '0';
  while (in = getchar(), in >= '0' && in <= '9') {
    num *= 10, num += in - '0';
  }
  if (IsN) num = -num;
  return true;
}
long long n, m, p;
long long num[maxn];
vector<int> v[maxn];
vector<pair<int, int>> g[maxn];
long long sum[maxn];
long long res[maxn];
void update(int k, int val) {
  while (k <= n) {
    sum[k] += val;
    k += k & -k;
  }
}
long long GetPos(int x) {
  long long ans = 0;
  while (x > 0) {
    ans += sum[x];
    x -= x & -x;
  }
  return ans;
}
void dfs(int u, int fa, int c) {
  for (auto x : g[u]) {
    long long temp = min((long long)c + x.first, n);
    update(c, x.second);
    update(temp + 1, -x.second);
  }
  res[u] = GetPos(c);
  for (int e : v[u]) {
    if (e == fa) continue;
    dfs(e, u, c + 1);
  }
  for (auto x : g[u]) {
    long long temp = min((long long)c + x.first, n);
    update(c, -x.second);
    update(temp + 1, x.second);
  }
}
int main() {
  read(n);
  for (int i = 1; i <= n - 1; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    v[x].push_back(y);
    v[y].push_back(x);
  }
  read(m);
  for (int i = 1; i <= m; i++) {
    int x, y, z;
    scanf("%d%d%d", &x, &y, &z);
    g[x].push_back({y, z});
  }
  dfs(1, 1, 1);
  for (int i = 1; i <= n; i++) printf("%lld ", res[i]);
  return 0;
}
