#include <bits/stdc++.h>
using namespace std;
const long long N = 300010;
vector<long long> adj[N];
vector<long long> dis[N];
long long cambio[N];
long long agrega[N];
long long quita[N];
long long ans[N];
long long parent[N];
long long dist[N];
bool vis[N];
long long dmx;
deque<pair<long long, long long> > q;
long long anc[N][40];
void procesa(long long x, long long d, long long &cnt, long long p) {
  if (p == -1) {
    parent[x] = p;
    dist[x] = d;
    dmx = max(dmx, d);
    q.push_back(make_pair(x, d));
    dis[d].push_back(x);
    cambio[x] = cnt;
    vis[x] = true;
    cnt++;
  } else {
    q.push_back(make_pair(x, d));
    vis[x] = true;
    cambio[x] = cnt;
    cnt++;
    x = cambio[x];
    p = cambio[p];
    parent[x] = p;
    dist[x] = d;
    dmx = max(dmx, d);
    dis[d].push_back(x);
  }
  return;
}
void bfs(long long x) {
  long long cnt = 1;
  dmx = 0;
  procesa(x, 0, cnt, -1);
  while (!q.empty()) {
    long long u = q.front().first;
    long long d = q.front().second;
    q.pop_front();
    long long sz = adj[u].size();
    for (long long i = 0; i < sz; i++) {
      long long v = adj[u][i];
      if (!vis[v]) {
        procesa(v, d + 1, cnt, u);
      }
    }
  }
  return;
}
void bfs2(long long x) {
  for (long long i = 0; i < N; i++) {
    vis[i] = false;
  }
  deque<long long> q;
  q.push_back(x);
  ans[x] = ans[0] + agrega[x] - quita[x];
  vis[x] = true;
  while (!q.empty()) {
    long long u = q.front();
    q.pop_front();
    long long sz = adj[u].size();
    for (long long i = 0; i < sz; i++) {
      long long v = adj[u][i];
      if (!vis[v]) {
        ans[cambio[v]] = ans[cambio[u]] + agrega[cambio[v]] - quita[cambio[v]];
        vis[v] = true;
        q.push_back(v);
      }
    }
  }
  return;
}
void build(long long n) {
  for (long long i = 0; i <= n; i++) {
    for (long long j = 0; (1ll << j) <= n; j++) {
      anc[i][j] = -1;
    }
  }
  for (long long i = 0; i <= n; i++) {
    anc[i][0] = parent[i];
  }
  for (long long j = 1; (1ll << j) <= n; j++) {
    for (long long i = 0; i <= n; i++) {
      if (anc[i][j - 1] != -1) {
        anc[i][j] = anc[anc[i][j - 1]][j - 1];
      }
    }
  }
  return;
}
long long f(long long pos, long long d, long long dd) {
  long long u = dis[d][pos];
  for (long long i = 0; i < 40; i++) {
    if (((dd >> i) & 1) == 1) {
      u = anc[u][i];
    }
  }
  return u;
}
long long bb(long long l, long long r, long long t, long long x, long long d,
             long long dd) {
  while (l != r) {
    long long med = (l + r) / 2;
    if (t == 0) {
      if (f(med, d, dd) < x) {
        l = med + 1;
      } else {
        r = med;
      }
    } else {
      if (f(med, d, dd) <= x) {
        l = med + 1;
      } else {
        r = med;
      }
    }
  }
  if (t == 0) {
    if (f(l, d, dd) < x) {
      l++;
    }
  } else {
    if (f(l, d, dd) <= x) {
      l++;
    }
  }
  return l;
}
void quitando(long long x, long long d, long long w) {
  if (dist[x] + d > dmx) return;
  long long dd = d;
  d = dist[x] + d;
  long long l = bb(0, dis[d].size() - 1, 0, x, d, dd);
  long long r = bb(0, dis[d].size() - 1, 1, x, d, dd);
  r--;
  if (l <= r) {
    quita[dis[d][l]] += w;
    quita[dis[d][r] + 1] -= w;
  }
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(10);
  cout << fixed;
  long long n, x, y, w;
  cin >> n;
  for (long long i = 0; i < n - 1; i++) {
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  bfs(1);
  build(n);
  long long q;
  cin >> q;
  for (long long i = 0; i < q; i++) {
    cin >> x >> y >> w;
    x = cambio[x];
    agrega[x] += w;
    quitando(x, y + 1, w);
  }
  for (long long i = 1; i <= n; i++) {
    quita[i] = quita[i] + quita[i - 1];
  }
  bfs2(1);
  for (long long i = 1; i <= n; i++) {
    cout << ans[cambio[i]] << " ";
  }
  cout << endl;
  return 0;
}
