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.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	
	static class Reader 
    { 
        final private int BUFFER_SIZE = 1 << 16; 
        private DataInputStream din; 
        private byte[] buffer; 
        private int bufferPointer, bytesRead; 
  
        public Reader() 
        { 
            din = new DataInputStream(System.in); 
            buffer = new byte[BUFFER_SIZE]; 
            bufferPointer = bytesRead = 0; 
        } 
  
        public Reader(String file_name) throws IOException 
        { 
            din = new DataInputStream(new FileInputStream(file_name)); 
            buffer = new byte[BUFFER_SIZE]; 
            bufferPointer = bytesRead = 0; 
        } 
  
        public 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 int nextInt() 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 long nextLong() 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 double nextDouble() 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 void fillBuffer() throws IOException 
        { 
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE); 
            if (bytesRead == -1) 
                buffer[0] = -1; 
        } 
  
        private byte read() throws IOException 
        { 
            if (bufferPointer == bytesRead) 
                fillBuffer(); 
            return buffer[bufferPointer++]; 
        } 
  
        public void close() throws IOException 
        { 
            if (din == null) 
                return; 
            din.close(); 
        } 
    } 
	
	public static void main(String[] args) throws Exception
	{
		StringBuilder sb=new StringBuilder();
		
		Reader s=new Reader();
		
		int n=s.nextInt();
		
		ArrayList<Integer>[] arr=new ArrayList[n+1];
		
		for(int i=0;i<n+1;i++)
		{
			ArrayList<Integer> list=new ArrayList<>();
			arr[i]=list;
		}
		
		for(int i=0;i<n-1;i++)
		{
			int a=s.nextInt();
			int b=s.nextInt();
			
			arr[a].add(b);
			arr[b].add(a);
		}
		
		ArrayList<pair>[] query=new ArrayList[n+1];
		
		for(int i=0;i<n+1;i++)
		{
			ArrayList<pair> list=new ArrayList<>();
			query[i]=list;
		}
		
		int q=s.nextInt();
		
		for(int i=0;i<q;i++)
		{
			int v=s.nextInt();
			int d=s.nextInt();
			int x=s.nextInt();
			
			pair p=new pair(d,x);
			
			query[v].add(p);
		}
		
		int[] visited=new int[n+1];
		LazySegmentTree st=new LazySegmentTree(new long[n+1]);
		long[] ans=new long[n+1];
		
		dfs(arr,query,1,visited,st,ans,0);
		
		for(int i=1;i<n+1;i++)
		{
			sb.append(ans[i]);
			sb.append(" ");
		}
		
		System.out.println(sb);
		
	}
	
	public static void dfs(ArrayList<Integer>[] arr,ArrayList<pair>[] query,int curr,int[] visited,LazySegmentTree st,long[] ans,int h)
	{
		visited[curr]=1;
		
		for(int i=0;i<query[curr].size();i++)
		{
			int d=query[curr].get(i).dist;
			int x=query[curr].get(i).add;
			
			st.update(h,h+d, x);
		}
		
		ans[curr]=st.query(h);
		
		for(int i=0;i<arr[curr].size();i++)
		{
			int now=arr[curr].get(i);
			
			if(visited[now]==0)
			{
				dfs(arr,query,now,visited,st,ans,h+1);
			}
		}
		
		for(int i=0;i<query[curr].size();i++)
		{
			int d=query[curr].get(i).dist;
			int x=query[curr].get(i).add;
			
			st.update(h,h+d, -x);
		}
	}
	
}

class pair
{
	int dist;
	int add;
	
	public pair(int dist,int add)
	{
		this.dist=dist;
		this.add=add;
	}
}

class LazySegmentTree {
	
	long[] arr;
	long[] lazy;
	int size;
	
	public LazySegmentTree(long[] input)
	{
		this.size=input.length;
		
		arr=new long[4*size];
		lazy=new long[4*size];
		
		makeTree(input,0,size-1,0);
	}
	
	private void makeTree(long[] input,int start,int end,int pos)
	{
		if(start==end)
		{
			this.arr[pos]=input[start];
			return;
		}
		
		int mid=(start+end)/2;
		
		makeTree(input,start,mid,2*pos+1);
		makeTree(input,mid+1,end,2*pos+2);
		
		arr[pos]=arr[2*pos+1]+arr[2*pos+2];
		
		return;
	}
	
	public void update(int r1,int r2,long data)
	{
		update(r1,r2,0,size-1,0,data);
	}
	
	private void update(int r1,int r2,int start,int end,int pos,long data)
	{
		// update the tree if not up to date
		if(this.lazy[pos]!=0)
		{
			if(start!=end)
			{
				this.lazy[2*pos+1]+=this.lazy[pos];
				this.lazy[2*pos+2]+=this.lazy[pos];
			}
			
			this.arr[pos]=this.arr[pos]+this.lazy[pos];
			this.lazy[pos]=0;
			
		}
		
		// no overlap
		if(r2<start||r1>end)
			return;
		
		// total overlap
		else if(r1<=start&&r2>=end)
		{
			this.arr[pos]+=data;
			
			if(start!=end)
			{
				this.lazy[2*pos+1]+=data;
				this.lazy[2*pos+2]+=data;
			}
			
			return;
		}
		
		// partial overlap
		
		int mid=(start+end)/2;
		
		update(r1,r2,start,mid,2*pos+1,data);
		update(r1,r2,mid+1,end,2*pos+2,data);
		
		this.arr[pos]=this.arr[2*pos+1]+this.arr[2*pos+2];
		
		return;
		
	}

	public long query(int r1,int r2)
	{
		return query(r1,r2,0,this.size-1,0);
	}
	
	public long query(int r)
	{
		return query(r,r,0,this.size-1,0);
	}
	
	private long query(int r1,int r2,int start,int end,int pos)
	{
		if(this.lazy[pos]!=0)
		{
			// not a leaf node
			if(start!=end)
			{
				this.lazy[2*pos+1]+=this.lazy[pos];
				this.lazy[2*pos+2]+=this.lazy[pos];
			}
			
			this.arr[pos]+=this.lazy[pos];
			this.lazy[pos]=0;
		}
		
		
		// total overlap
		if(r1<=start&&r2>=end)
		{
			return this.arr[pos];
		}
		
		// no overlap
		else if(r2<start||r1>end)
		{
			return 0;
		}
		
		// partial overlap
		
		int mid=(start+end)/2;
		
		long left=query(r1,r2,start,mid,2*pos+1);
		long right=query(r1,r2,mid+1,end,2*pos+2);
		
		return left+right;
	}
}
