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.*;

public class Solution {
	private static List<List<Node>> hor = new ArrayList();
	private static List<Node> nodeToLevel = new ArrayList();
	private static long[] ans;
	private static long[] verCount;
	private static long[] horCount;
	private static int time = 0;

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out = new PrintWriter(System.out);
		int n = Integer.parseInt(br.readLine());
		int[] from = new int[n - 1];
		int[] to = new int[n - 1];
		ans = new long[n + 1];
		verCount = new long[n + 1];
		horCount = new long[n + 1];

		for (int i = 0; i < n - 1; i++) {
			StringTokenizer st = new StringTokenizer(br.readLine());
			from[i] = Integer.parseInt(st.nextToken());
			to[i] = Integer.parseInt(st.nextToken());
		}

		int[][] g = construct(n + 1, from, to);
		// Arrays.stream(g).forEach(e->System.out.println(Arrays.toString(e)));

		for (int i = 0; i <= n; i++) {
			hor.add(new ArrayList());
			nodeToLevel.add(new Node(0, 0, 0, 0, 0));
		}

		DFS(g, 1, -1, 1);
		// System.out.println(nodeToLevel);
		// hor.stream().forEach(e->System.out.println(e));

		int q = Integer.parseInt(br.readLine());

		for (int i = 0; i < q; i++) {
			StringTokenizer st = new StringTokenizer(br.readLine());
			int v = Integer.parseInt(st.nextToken());
			int d = Integer.parseInt(st.nextToken());
			long x = Integer.parseInt(st.nextToken());

			verCount[v] += x;
			Node curNode = nodeToLevel.get(v);
			int distance = curNode.level + d + 1;

			if (distance > n || hor.get(distance).size() == 0)
				continue;

			List<Node> nodes = hor.get(distance);
			int[] extremes = binarySearch(nodes, curNode.st, curNode.endt);
			if (extremes[0] == -1)
				continue;
			//System.out.println(extremes[0] + " " + extremes[1]);
			Node left = nodes.get(extremes[0]);
			left.count += (-x);
			if (extremes[1] < nodes.size()) {
				Node right = nodes.get(extremes[1]);
				right.count += x;
			}
		}

		for (int i = 1; i <= n; i++) {
			long horizontalCount = 0;
			for (Node node : hor.get(i)) {
				horizontalCount += node.count;
				horCount[node.vertex] += horizontalCount;
			}
		}
		//System.out.println("horCount = " + Arrays.toString(horCount) + " verCount = " + Arrays.toString(verCount));
		 findAnsDFS(g,1,-1,0);
		 for(int i=1;i<=n;i++)
	           out.print(ans[i]+" ");
		 out.close();
		
	}

	private static void findAnsDFS(int[][] g, int u, int p, long count) {
		ans[u] = count + horCount[u] + verCount[u];

		for (int v : g[u]) {
			if (v == p)
				continue;
			findAnsDFS(g, v, u, ans[u]);
		}
	}

	private static int[] binarySearch(List<Node> nodes, int st, int endt) {
		int low = 0, high = nodes.size() - 1;
		int[] extremes = new int[2];

		while (low < high) {
			int mid = (low + high) / 2;
			Node n = nodes.get(mid);
			if (n.st > st)
				high = mid;
			else
				low = mid + 1;
		}
		if (nodes.get(low).st < st)
			return new int[] { -1, -1 };

		extremes[0] = low;

		high = nodes.size() - 1;

		while (low < high) {
			int mid = (low + high) / 2;
			Node n = nodes.get(mid);
			if (n.endt > endt)
				high = mid;
			else
				low = mid + 1;
		}

		if (nodes.get(high).endt < endt)
			high++;
		extremes[1] = high;
		return extremes;
	}

	private static void DFS(int[][] g, int u, int p, int level) {
		int startTime = ++time;

		for (int v : g[u]) {
			if (v == p)
				continue;
			DFS(g, v, u, level + 1);
		}

		time++;
		Node node = new Node(startTime, time, u, level, 0);
		nodeToLevel.set(u, node);
		hor.get(level).add(node);
	}

	private static int[][] construct(int n, int[] from, int[] to) {
		int[][] g = new int[n][];
		int[] p = new int[n];
		for (int f : from)
			p[f]++;
		for (int t : to)
			p[t]++;
		for (int i = 0; i < n; i++)
			g[i] = new int[p[i]];
		for (int i = 0; i < from.length; i++) {
			g[from[i]][--p[from[i]]] = to[i];
			g[to[i]][--p[to[i]]] = from[i];
		}
		return g;
	}
}

class Node {
	int st = 0, endt = 0, vertex = 0, level = 0;
	long count = 0;

	Node(int st, int endt, int vertex, int level, long count) {
		this.st = st;
		this.endt = endt;
		this.vertex = vertex;
		this.level = level;
		this.count = count;
	}

	@Override
	public String toString() {
		return "startTime = " + st + " endTime = " + endt + " vertex = " + vertex + " level = " + level + " count = "
				+ count;
	}
}