#include <bits/stdc++.h>
using namespace std;
vector<int> trvs;
vector<vector<int> > adj;
vector<pair<pair<int, int>, long long> > v;
vector<pair<int, int> > tp;
int n, q, h[300001] = {}, id[300001] = {}, it = 0, acs[300001][20] = {},
          bh[300001] = {};
long long rs[300001] = {}, tp2 = 0;
bool cp(const int &a, const int &b) {
  return h[a] < h[b] || (h[a] == h[b] && id[a] < id[b]);
}
struct cp2 {
  bool operator()(const pair<pair<int, int>, long long> &a,
                  const pair<pair<int, int>, long long> &b) {
    return make_pair(a.first.first, id[a.first.second]) >
           make_pair(b.first.first, id[b.first.second]);
  }
};
bool cp3(const pair<pair<int, int>, long long> &a,
         const pair<pair<int, int>, long long> &b) {
  return make_pair(h[a.first.first], id[a.first.first]) <
         make_pair(h[b.first.first], id[b.first.first]);
}
priority_queue<pair<pair<int, int>, long long>,
               vector<pair<pair<int, int>, long long> >, cp2>
    pq;
void dfs(int u, int p) {
  h[u] = (p == -1) ? 0 : (h[p] + 1);
  acs[u][0] = p;
  id[u] = it++;
  bh[u] = 0;
  for (int i = 1; i < 20; i++) {
    acs[u][i] = -1;
    if (acs[u][i - 1] != -1) {
      acs[u][i] = acs[acs[u][i - 1]][i - 1];
    }
  }
  for (auto v : adj[u]) {
    if (v != p) {
      dfs(v, u);
      bh[u] = max(bh[u], bh[v] + 1);
    }
  }
}
int act(int u, int h) {
  for (int i = 0; i < 20; i++) {
    if (h & (1 << i)) {
      u = acs[u][i];
    }
  }
  return u;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    adj.push_back(vector<int>());
    trvs.push_back(i);
  }
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    adj[a - 1].push_back(b - 1);
    adj[b - 1].push_back(a - 1);
  }
  dfs(0, -1);
  cin >> q;
  for (int i = 0; i < q; i++) {
    pair<pair<int, int>, long long> tp;
    cin >> tp.first.first >> tp.first.second >> tp.second;
    tp.first.first--;
    tp.first.second = min(tp.first.second, bh[tp.first.first]);
    v.push_back(tp);
  }
  sort(v.begin(), v.end(), cp3);
  sort(trvs.begin(), trvs.end(), cp);
  int j = 0;
  for (int i = 0; i < n; i++) {
    if (i) {
      if (h[trvs[i]] > h[trvs[i - 1]]) {
        tp.clear();
        tp2 = 0;
      }
    }
    for (; j < v.size(); j++) {
      if (v[j].first.first == trvs[i]) {
        rs[trvs[i]] += v[j].second;
        pq.push({{h[trvs[i]] + v[j].first.second, trvs[i]}, v[j].second});
      } else {
        break;
      }
    }
    while (tp.size()) {
      if (id[tp.back().first] <
          id[act(trvs[i], h[trvs[i]] - h[tp.back().first])]) {
        tp2 -= (long long)tp.back().second;
        tp.pop_back();
      } else {
        break;
      }
    }
    while (pq.size()) {
      if (pq.top().first.first < h[trvs[i]]) {
        pq.pop();
      }
      if (pq.top().first.first == h[trvs[i]] &&
          id[pq.top().first.second] <
              id[act(trvs[i], h[trvs[i]] - h[pq.top().first.second])]) {
        pq.pop();
      }
      if (pq.top().first.first == h[trvs[i]] &&
          pq.top().first.second ==
              act(trvs[i], h[trvs[i]] - h[pq.top().first.second])) {
        tp2 += (long long)pq.top().second;
        tp.push_back({pq.top().first.second, pq.top().second});
        pq.pop();
      } else {
        break;
      }
    }
    for (auto tpp : adj[trvs[i]]) {
      if (tpp != acs[trvs[i]][0]) {
        rs[tpp] = rs[trvs[i]] - tp2;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    cout << rs[i];
    if (i < n - 1) {
      cout << " ";
    }
  }
  cout << "\n";
  return 0;
}
