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 A {
	static FastReader sc=null;
	static BIT bit;
	static int n;
	
	public static void main(String[] args) {
		sc=new FastReader();
		PrintWriter out=new PrintWriter(System.out);
		n=sc.nextInt();
		Node nodes[]=new Node[n];
		for(int i=0;i<n;i++)nodes[i]=new Node(i);
		
		bit=new BIT(n);
		for(int i=0;i+1<n;i++) {
			int v=sc.nextInt()-1,w=sc.nextInt()-1;
			nodes[v].adj.add(nodes[w]);
			nodes[w].adj.add(nodes[v]);
		}
		int q=sc.nextInt();
		for(int i=0;i<q;i++) {
			int v=sc.nextInt()-1,d=sc.nextInt(),x=sc.nextInt();
			nodes[v].queries.add(new Pair(d,x));
		}
		dfs(nodes[0],null);
		
		for(Node nn:nodes)out.print(nn.ans+" ");
		out.println();
		
		out.close();
		
	}
	
	static void dfs(Node v,Node par) {
		if(par!=null)v.depth=par.depth+1;
		
		//do operations here
		for(Pair e:v.queries) {
			int s=v.depth,end=Math.min(n,s+e.d);
			bit.rangeUpdate(s, end, e.x);
		}
		v.ans=bit.pointSum(v.depth);
		
		//call for the children
		for(Node nn:v.adj) {
			if(nn!=par)dfs(nn,v);
		}
		
		//undo here
		for(Pair e:v.queries) {
			int s=v.depth,end=Math.min(n,s+e.d);
			bit.rangeUpdate(s, end, -e.x);
		}
	}
	static class BIT{
		int n;
		long tree[];
		
		BIT(int n){
			this.n=n;
			tree=new long[n+5];
		}
		
		//rangeQueries
		
		void pointUpdate(int i,int val) {
			i++;
			while(i<=n) {
				tree[i]+=val;
				i += (i & -i);
			}
		}
		void rangeUpdate(int i,int j,int sum) {
			pointUpdate(i,sum);
			pointUpdate(j+1,-sum);
		}
		
		//Point Queries
		long sum(int i) {
			i++;
			long sum=0;
			while(i>0) {
				sum+=(tree[i]);
				i -= (i & -i);
			}
			return sum;
		}
		
		long pointSum(int i) {
			return sum(i);
		}
		
		
		
	}
	static class Node{
		int id,depth=0;
		long ans;
		ArrayList<Node> adj=new ArrayList<>();
		ArrayList<Pair> queries=new ArrayList<>();
		
		Node(int id){
			this.id=id;
		}
	}
	static class Pair{
		int d,x;
		Pair(int d,int x){
			this.d=d;
			this.x=x;
		}
	}
	
	
	static int[] ruffleSort(int a[]) {
		ArrayList<Integer> al=new ArrayList<>();
		for(int i:a)al.add(i);
		Collections.sort(al);
		for(int i=0;i<a.length;i++)a[i]=al.get(i);
		return a;
	}
	
	static void print(int a[]) {
		for(int e:a) {
			System.out.print(e+" ");
		}
		System.out.println();
	}
	
	static class FastReader{
		
		StringTokenizer st=new StringTokenizer("");
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		
		String next() {
			while(!st.hasMoreTokens()) 
				try {
					st=new StringTokenizer(br.readLine());
				}
			   catch(IOException e){
				   e.printStackTrace();
			   }
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		
		long nextLong() {
			return Long.parseLong(next());
		}
		
		int[] readArray(int n) {
			int a[]=new int[n];
			for(int i=0;i<n;i++)a[i]=sc.nextInt();
			return a;
		}
	}
	
	
}
