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

public class E {
	private static InputReader in = new InputReader(System.in);
	private static PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) {
		new E().solve();
	}

	private int timer = 0;
	private int n;
	private int[][] a;
	private int[] D;
	private long[] ans;
	private ArrayList<int[]>[] U;
	private BIT bit;

	private final void solve() {
		n = in.nextInt();

		ArrayList<Integer>[] adj = new ArrayList[n + 1];
		for(int i = 1; i <= n; ++i) {
			adj[i] = new ArrayList<>();
		}
		for(int i = 1; i < n; ++i) {
			int u = in.nextInt();
			int v = in.nextInt();
			adj[u].add(v);
			adj[v].add(u);
		}

		a = new int[n + 1][];
		U = new ArrayList[n + 1];
		D = new int[n + 1];
		ans = new long[n + 1];
		for(int i = 1; i <= n; ++i) {
			a[i] = new int[adj[i].size()];
			for(int j = 0; j < adj[i].size(); ++j) {
				a[i][j] = adj[i].get(j);
			}
			U[i] = new ArrayList<>();
		}

		int m = in.nextInt();
		while(m-- > 0) {
			int u = in.nextInt();
			int d = in.nextInt();
			int add = in.nextInt();

			U[u].add(new int[]{ d, add });
		}

		bit = new BIT(n + n);
		dfs(1, 0);

		for(int i = 1; i <= n; ++i) {
			out.print(ans[i] + " ");
		}
		done();
	}

	private final void dfs(int u, int p) {
		D[u] = D[p] + 1;

		for(int[] update : U[u]) {
			bit.update(D[u], Math.min(D[u] + update[0], n << 1), update[1]);
		}

		ans[u] = bit.get(D[u]);
		for(int v : a[u]) {
			if(v != p) {
				dfs(v, u);
			}
		}

		for(int[] update : U[u]) {
			bit.update(D[u], Math.min(D[u] + update[0], n << 1), -update[1]);
		}
	}

	private static final class BIT {
		long[] B;
		int n;

		public BIT(int n) {
			this.n = n + 5;
			this.B = new long[this.n];
		}
		public void update(int i, long v) {
			while(i < n) {
				B[i] += v;
				i += i&-i;
			}
		}
		public long get(int i) {
			long s = 0;
			while(i > 0) {
				s += B[i];
				i -= i&-i;
			}
			return s;
		}
		public void update(int i, int j, long v) {
			update(i, v);
			update(j+1, -v);
		}
	}

	private final void done() {
		out.flush();
		out.close();
		System.exit(0);
	}
}

class InputReader {
	private InputStream stream;
	private byte[] buf = new byte[1024 << 3];
	private int curChar;
	private int numChars;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int[] readIntArray(int tokens) {
		int[] ret = new int[tokens];
		for (int i = 0; i < tokens; i++) {
			ret[i] = nextInt();
		}
		return ret;
	}

	public int read() {
		if (this.numChars == -1) {
			throw new InputMismatchException();
		} else {
			if (this.curChar >= this.numChars) {
				this.curChar = 0;

				try {
					this.numChars = this.stream.read(this.buf);
				} catch (IOException ex) {
					throw new InputMismatchException();
				}

				if (this.numChars <= 0) {
					return -1;
				}
			}

			return this.buf[this.curChar++];
		}
	}

	public int nextInt() {
		int c;
		for (c = this.read(); isSpaceChar(c); c = this.read()) {
		}

		byte sgn = 1;
		if (c == 45) {
			sgn = -1;
			c = this.read();
		}

		int res = 0;

		while (c >= 48 && c <= 57) {
			res *= 10;
			res += c - 48;
			c = this.read();
			if (isSpaceChar(c)) {
				return res * sgn;
			}
		}

		throw new InputMismatchException();
	}

	public long nextLong() {
		int c;
		for (c = this.read(); isSpaceChar(c); c = this.read()) {
		}

		byte sgn = 1;
		if (c == 45) {
			sgn = -1;
			c = this.read();
		}

		long res = 0;

		while (c >= 48 && c <= 57) {
			res *= 10L;
			res += c - 48;
			c = this.read();
			if (isSpaceChar(c)) {
				return res * sgn;
			}
		}
		throw new InputMismatchException();
	}

	public double nextDouble() {
		double ret = 0, div = 1;
		int 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;
	}

	public String next() {
		int c;
		while (isSpaceChar(c = this.read())) {
		}

		StringBuilder result = new StringBuilder();
		result.appendCodePoint(c);

		while (!isSpaceChar(c = this.read())) {
			result.appendCodePoint(c);
		}

		return result.toString();
	}

	public String nextLine() {
		int c;
		StringBuilder result = new StringBuilder();
		boolean read = false;
		while ((c = this.read()) != '\n') {
			if (c == -1)
				return null;
			result.appendCodePoint(c);
			read = true;
		}
		if (!read)
			return null;
		return result.toString();
	}

	public static boolean isSpaceChar(int c) {
		return c == 32 || c == 10 || c == 13 || c == 9 || c == -1;
	}
}