#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pli = pair<ll, int>;
const int INF = 0x3f3f3f3f, N = 3e5 + 5;
const ll LINF = 1e18 + 5;
int n, m;
vector<int> G[N];
int dep[N];
vector<pii> op[N];
ll ans[N];
struct seg {
  int l, r;
  ll lazy, v;
} t[N << 2];
void pushup(int p) { t[p].v = t[p << 1].v + t[p << 1 | 1].v; }
void pushdown(int p) {
  ll &x = t[p].lazy;
  t[p << 1].lazy += x;
  t[p << 1].v += x;
  t[p << 1 | 1].lazy += x;
  t[p << 1 | 1].v += x;
  x = 0;
}
void build(int p, int l, int r) {
  t[p].l = l, t[p].r = r, t[p].lazy = t[p].v = 0;
  if (l == r) return;
  int mid = (l + r) >> 1;
  build(p << 1, l, mid);
  build(p << 1 | 1, mid + 1, r);
}
void update(int p, int x, int y, int val) {
  int l = t[p].l, r = t[p].r;
  if (l >= x && r <= y) {
    t[p].v += val;
    t[p].lazy += val;
    return;
  }
  if (t[p].lazy) pushdown(p);
  int mid = (l + r) >> 1;
  if (x <= mid) update(p << 1, x, y, val);
  if (y > mid) update(p << 1 | 1, x, y, val);
  pushup(p);
}
ll query(int p, int x) {
  int l = t[p].l, r = t[p].r;
  if (l == r) return t[p].v;
  if (t[p].lazy) pushdown(p);
  int mid = (l + r) >> 1;
  if (x <= mid)
    return query(p << 1, x);
  else
    return query(p << 1 | 1, x);
}
void dfs(int u, int fa) {
  for (int v : G[u]) {
    if (v == fa) continue;
    dep[v] = dep[u] + 1;
    dfs(v, u);
  }
}
void dfs2(int u, int fa) {
  for (auto it : op[u]) update(1, dep[u], dep[u] + it.first, it.second);
  ans[u] = query(1, dep[u]);
  for (int v : G[u]) {
    if (v == fa) continue;
    dfs2(v, u);
  }
  for (auto it : op[u]) update(1, dep[u], dep[u] + it.first, -it.second);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i < n; i++) {
    int u, v;
    cin >> u >> v;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  dep[1] = 1;
  dfs(1, 0);
  build(1, 1, n);
  cin >> m;
  for (int i = 1; i <= m; i++) {
    int x, y, z;
    cin >> x >> y >> z;
    op[x].push_back(make_pair(min(y, n - dep[x]), z));
  }
  dfs2(1, 0);
  for (int i = 1; i <= n; i++) cout << ans[i] << " \n"[i == n];
  return 0;
}
