Vasya has a tree consisting of n vertices with root in vertex 1. At first all vertices has 0 written on it.

Let d(i, j) be the distance between vertices i and j, i.e. number of edges in the shortest path from i to j. Also, let's denote k-subtree of vertex x — set of vertices y such that next two conditions are met: 

  * x is the ancestor of y (each vertex is the ancestor of itself); 
  * d(x, y) ≤ k. 



Vasya needs you to process m queries. The i-th query is a triple v_i, d_i and x_i. For each query Vasya adds value x_i to each vertex from d_i-subtree of v_i.

Report to Vasya all values, written on vertices of the tree after processing all queries.

Input

The first line contains single integer n (1 ≤ n ≤ 3 ⋅ 10^5) — number of vertices in the tree.

Each of next n - 1 lines contains two integers x and y (1 ≤ x, y ≤ n) — edge between vertices x and y. It is guarantied that given graph is a tree.

Next line contains single integer m (1 ≤ m ≤ 3 ⋅ 10^5) — number of queries.

Each of next m lines contains three integers v_i, d_i, x_i (1 ≤ v_i ≤ n, 0 ≤ d_i ≤ 10^9, 1 ≤ x_i ≤ 10^9) — description of the i-th query.

Output

Print n integers. The i-th integers is the value, written in the i-th vertex after processing all queries.

Examples

Input


5
1 2
1 3
2 4
2 5
3
1 1 1
2 0 10
4 10 100


Output


1 11 1 100 0 


Input


5
2 3
2 1
5 4
3 4
5
2 0 4
3 10 1
1 2 3
2 3 10
1 1 7


Output


10 24 14 11 11 

Note

In the first exapmle initial values in vertices are 0, 0, 0, 0, 0. After the first query values will be equal to 1, 1, 1, 0, 0. After the second query values will be equal to 1, 11, 1, 0, 0. After the third query values will be equal to 1, 11, 1, 100, 0.
#include <bits/stdc++.h>
using namespace std;
template <typename num_t>
inline void addmod(num_t& a, const long long& b, const int& m) {
  a = (a + b) % m;
  if (a < 0) a += m;
}
template <typename num_t>
inline void update_max(num_t& a, const num_t& b) {
  a = max(a, b);
}
template <typename num_t>
inline void update_min(num_t& a, const num_t& b) {
  a = min(a, b);
}
template <typename num_t>
num_t gcd(num_t lhs, num_t rhs) {
  return !lhs ? rhs : gcd(rhs % lhs, lhs);
}
template <typename num_t>
num_t pw(num_t n, num_t k, num_t mod) {
  long long res = 1;
  for (; k; k >>= 1) {
    if (k & 1) res = res * n % mod;
    n = 1ll * n * n % mod;
  }
  return (num_t)res;
}
const int inf = 1e9 + 7;
const long long ll_inf = 1ll * inf * inf;
const int MAX_N = 300000 + 7;
const int mod = 998244353;
template <typename num_t>
class SegmentTree {
 public:
  void init(int l, int r) {
    tree.resize((r - l + 1) << 1);
    cnt = 0;
    tree_root = &tree[cnt++];
    build_tree(*tree_root, l, r);
  }
  void update(int left_index, int right_index, num_t val) {
    update(*tree_root, left_index, right_index, val);
  }
  num_t get(int index) { return get(*tree_root, index, index); }
  num_t get(int left_index, int right_index) {
    return get(*tree_root, left_index, right_index);
  }

 private:
  struct node {
    static const num_t nil = 0;
    node *left_child, *right_child;
    int left_index, right_index;
    num_t value;
    node() { init(0, 0, nullptr, nullptr); }
    void init(int left_index_, int right_index_, node* left_, node* right_) {
      left_child = left_;
      right_child = right_;
      left_index = left_index_;
      right_index = right_index_;
      value = 0;
    }
    int size() const { return right_index - left_index + 1; }
    void push_down(num_t v) { value += v; }
    void merge_node() { auto &lhs = *left_child, &rhs = *right_child; }
    void lazy_update() {
      if (value) {
        if (left_child != nullptr) left_child->push_down(value);
        if (right_child != nullptr) right_child->push_down(value);
        value = 0;
      }
    }
  };
  vector<node> tree;
  node* tree_root;
  int cnt = 0;
  void build_tree(node& root, int left, int right) {
    if (left == right) {
      root.init(left, right, nullptr, nullptr);
      return;
    }
    int mid = (left + right) >> 1;
    int lhs = cnt++, rhs = cnt++;
    build_tree(tree[lhs], left, mid);
    build_tree(tree[rhs], mid + 1, right);
    root.init(left, right, &tree[lhs], &tree[rhs]);
  }
  void update(node& root, int u, int v, num_t val) {
    if (u > root.right_index || v < root.left_index) return;
    if (u <= root.left_index && root.right_index <= v) {
      root.push_down(val);
      return;
    }
    root.lazy_update();
    update(*root.left_child, u, v, val);
    update(*root.right_child, u, v, val);
    root.merge_node();
  }
  num_t get(node& root, int u, int v) {
    if (u <= root.left_index && root.right_index <= v) return root.value;
    if (u > root.right_index || v < root.left_index) return 0;
    root.lazy_update();
    auto lhs = get(*root.left_child, u, v);
    auto rhs = get(*root.right_child, u, v);
    return max(lhs, rhs);
  }
};
SegmentTree<long long> segment_tree;
int n;
vector<int> adj[MAX_N];
int depth[MAX_N];
vector<pair<int, int>> query[MAX_N];
long long ans[MAX_N];
void dfs(int u, int r) {
  if (r != -1) depth[u] = depth[r] + 1;
  for (auto p : query[u]) {
    int mx = p.first + depth[u];
    mx = min(mx, n - 1);
    segment_tree.update(depth[u], mx, p.second);
  }
  ans[u] = segment_tree.get(depth[u]);
  for (int v : adj[u])
    if (v != r) {
      dfs(v, u);
    }
  for (auto p : query[u]) {
    int mx = p.first + depth[u];
    mx = min(mx, n - 1);
    segment_tree.update(depth[u], mx, -p.second);
  }
}
void solve() {
  cin >> n;
  for (int i = (1), _b = (n); i < _b; ++i) {
    int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  int q;
  cin >> q;
  while (q-- > 0) {
    int v, d, x;
    cin >> v >> d >> x;
    query[v].push_back({d, x});
  }
  segment_tree.init(0, n - 1);
  dfs(1, -1);
  for (int i = 1; i <= n; ++i) cout << ans[i] << ' ';
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  const bool multiple_test = false;
  int test = 1;
  if (multiple_test) cin >> test;
  for (int i = 0; i < test; ++i) {
    solve();
  }
}
