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.
import java.util.*;
import java.io.*;

public class _1076_E_VasyaAndATree {

	static ArrayList<Integer> graph[];
	static ArrayList<Integer> ht[];
	static ArrayList<Integer> val[];
	static int dep[], par[];
	static long ans[];
	static long BIT[];
	
	public static void main(String[] args) throws IOException {
		int N = readInt();
		graph = new ArrayList[N+1];
		ht = new ArrayList[N+1];
		val = new ArrayList[N+1];
		for(int i=1; i<=N; i++) {
			graph[i] = new ArrayList<>();
			ht[i] = new ArrayList<>();
			val[i] = new ArrayList<>();
		}
		for(int i =1; i<N; i++) {
			int a = readInt(), b = readInt();
			graph[a].add(b);
			graph[b].add(a);
		}
		int Q = readInt();
		for(int i = 1; i<=Q; i++) {
			int n = readInt(), d = readInt(), v = readInt();
			ht[n].add(d);
			val[n].add(v);
		}
		BIT = new long[N+1];
		ans = new long[N+1];
		dep = new int[N+1];
		par = new int[N+1];
		dep[1] = 1;
		dfs(1);
		for(int i = 1; i<=N; i++) {
			print(ans[i] + " ");
		}
		exit();
	}
	
	static void dfs(int n) {
		for(int i = 0; i<ht[n].size(); i++) {
			upd(dep[n], val[n].get(i));
			upd(dep[n] + ht[n].get(i) + 1, -val[n].get(i));
		}
		for(int i = dep[n]; i>0; i-=i&-i) {
			ans[n] += BIT[i];
		}
		for(int e : graph[n]) {
			if(e != par[n]) {
				dep[e] = dep[n] + 1;
				par[e] = n;
				dfs(e);
			}
		}
		for(int i = 0; i<ht[n].size(); i++) {
			upd(dep[n], -val[n].get(i));
			upd(dep[n] + ht[n].get(i) + 1, val[n].get(i));
		}
	}
	
	static void upd(int n, int v) {
		for(int i = n; i<BIT.length; i+=i&-i) {
			BIT[i]+=v;
		}
	}

	final private static int BUFFER_SIZE = 1 << 16;
	private static DataInputStream din = new DataInputStream(System.in);
	private static byte[] buffer = new byte[BUFFER_SIZE];
	private static int bufferPointer = 0, bytesRead = 0;
	static PrintWriter pr = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

	public static String readLine() throws IOException {
		byte[] buf = new byte[64]; // line length
		int cnt = 0, c;
		while ((c = Read()) != -1) {
			if (c == '\n')
				break;
			buf[cnt++] = (byte) c;
		}
		return new String(buf, 0, cnt);
	}

	public static String read() throws IOException {
		byte[] ret = new byte[1024];
		int idx = 0;
		byte c = Read();
		while (c <= ' ') {
			c = Read();
		}
		do {
			ret[idx++] = c;
			c = Read();
		} while (c != -1 && c != ' ' && c != '\n' && c != '\r');
		return new String(ret, 0, idx);
	}

	public static int readInt() throws IOException {
		int ret = 0;
		byte c = Read();
		while (c <= ' ')
			c = Read();
		boolean neg = (c == '-');
		if (neg)
			c = Read();
		do {
			ret = ret * 10 + c - '0';
		} while ((c = Read()) >= '0' && c <= '9');

		if (neg)
			return -ret;
		return ret;
	}

	public static long readLong() throws IOException {
		long ret = 0;
		byte c = Read();
		while (c <= ' ')
			c = Read();
		boolean neg = (c == '-');
		if (neg)
			c = Read();
		do {
			ret = ret * 10 + c - '0';
		} while ((c = Read()) >= '0' && c <= '9');
		if (neg)
			return -ret;
		return ret;
	}

	public static double readDouble() throws IOException {
		double ret = 0, div = 1;
		byte c = Read();
		while (c <= ' ')
			c = Read();
		boolean neg = (c == '-');
		if (neg)
			c = Read();

		do {
			ret = ret * 10 + c - '0';
		} while ((c = Read()) >= '0' && c <= '9');

		if (c == '.') {
			while ((c = Read()) >= '0' && c <= '9') {
				ret += (c - '0') / (div *= 10);
			}
		}

		if (neg)
			return -ret;
		return ret;
	}

	private static void fillBuffer() throws IOException {
		bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
		if (bytesRead == -1)
			buffer[0] = -1;
	}

	private static byte Read() throws IOException {
		if (bufferPointer == bytesRead)
			fillBuffer();
		return buffer[bufferPointer++];
	}

	static void print(Object o) {
		pr.print(o);
	}

	static void println(Object o) {
		pr.println(o);
	}

	static void flush() {
		pr.flush();
	}

	static void println() {
		pr.println();
	}

	static void exit() throws IOException {
		din.close();
		pr.close();
		System.exit(0);
	}
}
