#include <bits/stdc++.h>
using namespace std;
const int N = 300005;
inline int read() {
  int s = 0, w = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    s = s * 10 + ch - '0';
    ch = getchar();
  }
  return s * w;
}
int n, Q;
vector<int> adj[N];
struct node {
  int d, x;
  node(int d = 0, int x = 0) : d(d), x(x) {}
};
vector<node> q[N];
long long ans[N];
long long fw[N];
inline int lowbit(int x) { return x & (-x); }
inline void change(int x, int v) {
  for (; x <= n; x += lowbit(x)) fw[x] += v;
}
inline long long query(int x) {
  long long res = 0;
  for (; x; x -= lowbit(x)) res += fw[x];
  return res;
}
void dfs(int u, int fa, int dep) {
  int v, d, x;
  for (int i = 0; i < q[u].size(); i++) {
    d = q[u][i].d;
    x = q[u][i].x;
    change(dep, +x);
    if (dep + d + 1 <= n) change(dep + d + 1, -x);
  }
  ans[u] = query(dep);
  for (int i = 0; i < adj[u].size(); i++) {
    v = adj[u][i];
    if (v == fa) continue;
    dfs(v, u, dep + 1);
  }
  for (int i = 0; i < q[u].size(); i++) {
    d = q[u][i].d;
    x = q[u][i].x;
    change(dep, -x);
    if (dep + d + 1 <= n) change(dep + d + 1, +x);
  }
}
int main() {
  n = read();
  int u, v, d, x;
  for (int i = 2; i <= n; i++) {
    u = read();
    v = read();
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  Q = read();
  while (Q--) {
    v = read();
    d = read();
    x = read();
    q[v].push_back(node(d, x));
  }
  dfs(1, 0, 1);
  for (int i = 1; i <= n; i++) printf("%lld ", ans[i]);
  puts("");
  return 0;
}

### Prompt

Generate a cpp solution to the following problem:

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.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 300005;
inline int read() {
  int s = 0, w = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    s = s * 10 + ch - '0';
    ch = getchar();
  }
  return s * w;
}
int n, Q;
vector<int> adj[N];
struct node {
  int d, x;
  node(int d = 0, int x = 0) : d(d), x(x) {}
};
vector<node> q[N];
long long ans[N];
long long fw[N];
inline int lowbit(int x) { return x & (-x); }
inline void change(int x, int v) {
  for (; x <= n; x += lowbit(x)) fw[x] += v;
}
inline long long query(int x) {
  long long res = 0;
  for (; x; x -= lowbit(x)) res += fw[x];
  return res;
}
void dfs(int u, int fa, int dep) {
  int v, d, x;
  for (int i = 0; i < q[u].size(); i++) {
    d = q[u][i].d;
    x = q[u][i].x;
    change(dep, +x);
    if (dep + d + 1 <= n) change(dep + d + 1, -x);
  }
  ans[u] = query(dep);
  for (int i = 0; i < adj[u].size(); i++) {
    v = adj[u][i];
    if (v == fa) continue;
    dfs(v, u, dep + 1);
  }
  for (int i = 0; i < q[u].size(); i++) {
    d = q[u][i].d;
    x = q[u][i].x;
    change(dep, -x);
    if (dep + d + 1 <= n) change(dep + d + 1, +x);
  }
}
int main() {
  n = read();
  int u, v, d, x;
  for (int i = 2; i <= n; i++) {
    u = read();
    v = read();
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  Q = read();
  while (Q--) {
    v = read();
    d = read();
    x = read();
    q[v].push_back(node(d, x));
  }
  dfs(1, 0, 1);
  for (int i = 1; i <= n; i++) printf("%lld ", ans[i]);
  puts("");
  return 0;
}

```