#include <bits/stdc++.h>
const long long INF = (1e9 + 12312), MOD = 1e9 + 7;
const long double EPS = 0.0000000001;
using namespace std;
void print(vector<long long> a) {
  for (auto i : a) {
    cout << i << " ";
  }
  cout << "\n";
}
long long depth[3 * 100005];
vector<long long> g[3 * 100005];
vector<pair<long long, long long>> task[3 * 100005];
void dfs_depth(long long v, long long d, long long p) {
  depth[v] = d;
  for (auto i : g[v]) {
    if (i != p) {
      dfs_depth(i, d + 1, v);
    }
  }
}
multiset<pair<long long, long long>> taskNow;
long long addSum = 0;
long long ans[3 * 100005];
vector<long long> tree;
vector<long long> mod;
void build(long long v, long long l, long long r) {
  if (l == r) {
    tree[v] = 0;
  } else {
    long long m = (l + r) / 2;
    build(v * 2, l, m);
    build(v * 2 + 1, m + 1, r);
    tree[v] = max(tree[v * 2], tree[v * 2 + 1]);
  }
}
void push(long long v) {
  mod[v * 2] += mod[v];
  mod[v * 2 + 1] += mod[v];
  mod[v] = 0;
}
void update(long long v, long long l, long long r, long long cl, long long cr,
            long long val) {
  if (r < cl || cr < l) {
    return;
  }
  if (l <= cl && cr <= r) {
    mod[v] += val;
  } else {
    long long cm = (cl + cr) / 2;
    push(v);
    update(v * 2, l, r, cl, cm, val);
    update(v * 2 + 1, l, r, cm + 1, cr, val);
    tree[v] = max(tree[v * 2] + mod[v * 2], tree[v * 2 + 1] + mod[v * 2 + 1]);
  }
}
long long get(long long v, long long l, long long r, long long cl,
              long long cr) {
  if (r < cl || cr < l) {
    return -1e9;
  }
  if (l <= cl && cr <= r) {
    return tree[v] + mod[v];
  } else {
    long long cm = (cl + cr) / 2;
    push(v);
    long long resp =
        max(get(v * 2, l, r, cl, cm), get(v * 2 + 1, l, r, cm + 1, cr));
    tree[v] = max(tree[v * 2] + mod[v * 2], tree[v * 2 + 1] + mod[v * 2 + 1]);
    return resp;
  }
}
long long n;
void dfs(long long v, long long p) {
  for (auto i : task[v]) {
    long long willEnd = i.first + depth[v];
    update(1, depth[v], willEnd, 0, n - 1, i.second);
  }
  long long del = 0;
  ans[v] = get(1, depth[v], depth[v], 0, n - 1);
  for (auto i : g[v]) {
    if (i != p) {
      dfs(i, v);
    }
  }
  for (auto i : task[v]) {
    long long willEnd = i.first + depth[v];
    update(1, depth[v], willEnd, 0, n - 1, -i.second);
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cin >> n;
  tree.resize(n * 4 + 4);
  mod.resize(n * 4 + 4, 0);
  build(1, 0, n - 1);
  for (long long i = 0; i < n - 1; i++) {
    long long first, second;
    cin >> first >> second;
    first--, second--;
    g[first].push_back(second);
    g[second].push_back(first);
  }
  dfs_depth(0, 0, -1);
  long long m;
  cin >> m;
  for (long long i = 0; i < m; i++) {
    long long first, second, z;
    cin >> first >> second >> z;
    first--;
    task[first].push_back(make_pair(second, z));
  }
  dfs(0, -1);
  for (long long i = 0; i < n; i++) {
    cout << ans[i] << " ";
  }
  return 0;
}
