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;
const long long mod = (long long)1e9 + 7;
const long long inf = (long long)1e16;
const long double eps = 1e-12;
const long long N = (int)3e5 + 5;
const long long LOGN = 19;
const long double PI = 3.14159265358979323846;
inline long long mul(long long a, long long b, long long m = mod) {
  return (long long)(a * b) % m;
}
inline long long add(long long a, long long b, long long m = mod) {
  a += b;
  if (a >= m) a -= m;
  if (a < 0) a += m;
  return a;
}
inline long long power(long long a, long long b, long long m = mod) {
  if (b == 0) return 1;
  if (b == 1) return (a % m);
  long long x = power(a, b / 2, m);
  x = mul(x, x, m);
  if (b % 2) x = mul(x, a, m);
  return x;
}
int n, q;
long long ans[N];
vector<int> adj[N];
vector<pair<int, int> > queries[N];
struct node {
  long long val;
  long long lazy;
  node() {
    val = 0;
    lazy = 0;
  }
  inline void merge(node &l, node &r) { val = l.val + r.val; }
  inline void no_use() {
    val = 0;
    lazy = 0;
  }
};
node segtree[N << 2];
void propogate(int num, int start, int end, long long mul) {
  segtree[num].val += (end - start + 1) * mul * 1ll;
  if (start != end) {
    segtree[num + num + 1].lazy += mul;
    segtree[num + num + 2].lazy += mul;
  }
}
void update(int num, int start, int end, int l, int r, long long p) {
  if (segtree[num].lazy != 0) {
    propogate(num, start, end, segtree[num].lazy);
    segtree[num].lazy = 0;
  }
  if (start > end || start > r || end < l) return;
  if (start >= l && end <= r) {
    propogate(num, start, end, p);
    return;
  }
  int lc = num + num + 1, rc = lc + 1;
  int mid = (start + end) >> 1;
  update(lc, start, mid, l, r, p);
  update(rc, mid + 1, end, l, r, p);
  segtree[num].merge(segtree[lc], segtree[rc]);
}
node query(int num, int start, int end, int qs, int qe) {
  if (start > qe || end < qs) {
    node ret;
    ret.no_use();
    return ret;
  }
  if (segtree[num].lazy != 0) {
    propogate(num, start, end, segtree[num].lazy);
    segtree[num].lazy = 0;
  }
  if (start >= qs && end <= qe) {
    return segtree[num];
  }
  int lc = num + num + 1, rc = lc + 1;
  int mid = (start + end) >> 1;
  node lf = query(lc, start, mid, qs, qe);
  node rg = query(rc, mid + 1, end, qs, qe);
  node ret;
  ret.merge(lf, rg);
  return ret;
}
void dfs(int src, int par, int dep) {
  for (auto &it : queries[src]) {
    int upto = min(it.first + dep, (int)N - 1);
    update(0, 0, N - 1, dep, upto, it.second);
  }
  ans[src] = query(0, 0, N - 1, dep, dep).val;
  for (int u : adj[src]) {
    if (u == par) continue;
    dfs(u, src, dep + 1);
  }
  for (auto &it : queries[src]) {
    int upto = min(it.first + dep, (int)N - 1);
    update(0, 0, N - 1, dep, upto, -it.second);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  if (0) {
    freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r",
            stdin);
    freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w",
            stdout);
  }
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  cin >> q;
  for (int i = 0; i < q; i++) {
    int v, d, x;
    cin >> v >> d >> x;
    d = min(d, n);
    queries[v].push_back({d, x});
  }
  dfs(1, 1, 1);
  for (int i = 1; i <= n; i++) cout << ans[i] << ' ';
  return 0;
}
