#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
void _print(long long int t) { cerr << t; }
void _print(int t) { cerr << t; }
void _print(string t) { cerr << t; }
void _print(char t) { cerr << t; }
void _print(long double t) { cerr << t; }
void _print(double t) { cerr << t; }
void _print(unsigned long long t) { cerr << t; }
template <class T, class V>
void _print(pair<T, V> p);
template <class T>
void _print(vector<T> v);
template <class T>
void _print(set<T> v);
template <class T, class V>
void _print(map<T, V> v);
template <class T>
void _print(multiset<T> v);
template <class T, class V>
void _print(pair<T, V> p) {
  cerr << "{";
  _print(p.first);
  cerr << ",";
  _print(p.second);
  cerr << "}";
}
template <class T>
void _print(vector<T> v) {
  cerr << "[ ";
  for (T i : v) {
    _print(i);
    cerr << " ";
  }
  cerr << "]";
}
template <class T>
void _print(set<T> v) {
  cerr << "[ ";
  for (T i : v) {
    _print(i);
    cerr << " ";
  }
  cerr << "]";
}
template <class T>
void _print(multiset<T> v) {
  cerr << "[ ";
  for (T i : v) {
    _print(i);
    cerr << " ";
  }
  cerr << "]";
}
template <class T, class V>
void _print(map<T, V> v) {
  cerr << "[ ";
  for (auto i : v) {
    _print(i);
    cerr << " ";
  }
  cerr << "]";
}
long long int mod1 = 1e9 + 7;
long long int INF = 1e9 + 5;
long long int mod = 998244353;
struct segtree {
  long long int size = 1;
  vector<long long int> mini;
  segtree(vector<long long int> &a) {
    while (size < (long long int)a.size()) {
      size *= 2;
    }
    mini.resize(2 * size, 0);
    build(a);
  }
  void build(vector<long long int> &a) { build(0, 0, size, a); }
  void build(long long int x, long long int lx, long long int rx,
             vector<long long int> &a) {
    if (rx - lx == 1) {
      if (lx < a.size()) {
        mini[x] = a[lx];
      }
      return;
    }
    long long int m = lx + (rx - lx) / 2;
    build(2 * x + 1, lx, m, a);
    build(2 * x + 2, m, rx, a);
    mini[x] = mini[2 * x + 1] + mini[2 * x + 2];
  }
  void update(long long int index, long long int val) {
    update(0, 0, size, index, val);
  }
  void update(long long int x, long long int lx, long long int rx,
              long long int index, long long int val) {
    if (rx - lx == 1) {
      mini[x] = val;
      return;
    }
    long long int m = lx + (rx - lx) / 2;
    if (index < m) {
      update(2 * x + 1, lx, m, index, val);
    } else {
      update(2 * x + 2, m, rx, index, val);
    }
    mini[x] = mini[2 * x + 1] + mini[2 * x + 2];
  }
  long long int calc(long long int l, long long int r) {
    return calc(0, 0, size, l, r);
  }
  long long int calc(long long int x, long long int lx, long long int rx,
                     long long int l, long long int r) {
    if (rx <= l || lx >= r) {
      return 0;
    }
    if (lx >= l && rx <= r) {
      return mini[x];
    }
    long long int m = lx + (rx - lx) / 2;
    long long int ans =
        calc(2 * x + 1, lx, m, l, r) + calc(2 * x + 2, m, rx, l, r);
    return ans;
  }
};
void dfs(vector<vector<long long int>> &edges, long long int node,
         long long int pa, vector<long long int> &height, long long int h) {
  height[node] = h;
  for (auto ele : edges[node]) {
    if (ele == pa) continue;
    dfs(edges, ele, node, height, h + 1);
  }
  return;
}
void dfs(vector<vector<long long int>> &edges, vector<long long int> &height,
         segtree &dp, vector<vector<pair<long long int, long long int>>> &q,
         vector<long long int> &vals, long long int node, long long int pa,
         vector<long long int> &hvals) {
  for (auto ele : q[node]) {
    hvals[min(height[node] + ele.first, (long long int)hvals.size() - 1)] +=
        ele.second;
    dp.update(
        min(height[node] + ele.first, (long long int)hvals.size() - 1),
        hvals[min(height[node] + ele.first, (long long int)hvals.size() - 1)]);
  }
  vals[node] = dp.calc(height[node], (long long int)hvals.size());
  for (auto ele : edges[node]) {
    if (ele == pa) continue;
    dfs(edges, height, dp, q, vals, ele, node, hvals);
  }
  for (auto ele : q[node]) {
    hvals[min(height[node] + ele.first, (long long int)hvals.size() - 1)] -=
        ele.second;
    dp.update(
        min(height[node] + ele.first, (long long int)hvals.size() - 1),
        hvals[min(height[node] + ele.first, (long long int)hvals.size() - 1)]);
  }
}
void solve(long long int test_case) {
  long long int n;
  cin >> n;
  vector<vector<long long int>> edges(n + 1);
  for (long long int i = 0; i < n - 1; i++) {
    long long int x, y;
    cin >> x >> y;
    edges[x].push_back(y);
    edges[y].push_back(x);
  }
  long long int m;
  cin >> m;
  vector<long long int> height(n + 1);
  dfs(edges, 1, -1, height, 0);
  vector<vector<pair<long long int, long long int>>> q(n + 1);
  for (long long int i = 0; i < m; i++) {
    long long int v, d, x;
    cin >> v >> d >> x;
    q[v].push_back({d, x});
  }
  for (auto &ele : q) {
    sort(ele.begin(), ele.end());
  }
  vector<long long int> vals(n + 1), hvals(n + 1);
  segtree dp(hvals);
  dfs(edges, height, dp, q, vals, 1, -1, hvals);
  for (long long int i = 1; i <= n; i++) cout << vals[i] << " ";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int t = 1;
  long long int i = 1ll;
  while (t--) {
    solve(i);
    i++;
  }
}
