#include <bits/stdc++.h>
using namespace std;
int n, q;
const int N = 2e6 + 10;
long long tree[N], a[N];
int lev[N];
vector<pair<int, int> > vv[N];
vector<int> v[N];
int re;
void up(int ind, int st, int end, int uind, int uval) {
  if (uind > end || uind < st) return;
  if (st == end) {
    tree[ind] += uval;
    return;
  }
  int m = (st + end) / 2;
  up(ind * 2 + 1, st, m, uind, uval);
  up(ind * 2 + 2, m + 1, end, uind, uval);
  tree[ind] = tree[ind * 2 + 1] + tree[ind * 2 + 2];
}
long long get(int ind, int st, int end, int l, int r) {
  if (l <= st && end <= r) return tree[ind];
  if (l > end || r < st) return 0;
  int m = (st + end) / 2;
  return get(ind * 2 + 1, st, m, l, r) + get(ind * 2 + 2, m + 1, end, l, r);
}
void dfs(int x, int p) {
  lev[x] = lev[p] + 1;
  for (auto it : vv[x]) {
    up(0, 0, re, min(it.first + lev[x], re), it.second);
  }
  a[x] = get(0, 0, re, lev[x], re);
  for (auto it : v[x]) {
    if (it == p) continue;
    dfs(it, x);
  }
  for (auto it : vv[x]) up(0, 0, re, min(re, it.first + lev[x]), -it.second);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  re = n + 1;
  cin >> q;
  while (q--) {
    int x, y, z;
    cin >> x >> y >> z;
    vv[x].push_back({y, z});
  }
  dfs(1, 0);
  for (int i = 1; i < n + 1; i++) cout << a[i] << " ";
}
