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.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.InputMismatchException;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Queue;
import java.util.TreeMap;
				 
				 
				 
				 
				 
				 public class Solution2 implements Runnable
				{
				    static final long MAX = 464897L;
				    static class InputReader
				    {
				        private InputStream stream;
				        private byte[] buf = new byte[1024];
				        private int curChar;
				        private int numChars;
				        private SpaceCharFilter filter;
				        private BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
				 
				        public InputReader(InputStream stream)
				        {
				            this.stream = stream;
				        }
				        
				        public int read()
				        {
				            if (numChars==-1) 
				                throw new InputMismatchException();
				            
				            if (curChar >= numChars)
				            {
				                curChar = 0;
				                try 
				                {
				                    numChars = stream.read(buf);
				                }
				                catch (IOException e)
				                {
				                    throw new InputMismatchException();
				                }
				                
				                if(numChars <= 0)                
				                    return -1;
				            }
				            return buf[curChar++];
				        }
				     
				        public String nextLine()
				        {
				            String str = "";
				            try
				            {
				                str = br.readLine();
				            }
				            catch (IOException e)
				            {
				                e.printStackTrace();
				            }
				            return str;
				        }
				        public int nextInt()
				        {
				            int c = read();
				            
				            while(isSpaceChar(c)) 
				                c = read();
				            
				            int sgn = 1;
				            
				            if (c == '-') 
				            {
				                sgn = -1;
				                c = read();
				            }
				            
				            int res = 0;
				            do 
				            {
				                if(c<'0'||c>'9') 
				                    throw new InputMismatchException();
				                res *= 10;
				                res += c - '0';
				                c = read();
				            }
				            while (!isSpaceChar(c)); 
				            
				            return res * sgn;
				        }
				        
				        public long nextLong() 
				        {
				            int c = read();
				            while (isSpaceChar(c))
				                c = read();
				            int sgn = 1;
				            if (c == '-') 
				            {
				                sgn = -1;
				                c = read();
				            }
				            long res = 0;
				            
				            do 
				            {
				                if (c < '0' || c > '9')
				                    throw new InputMismatchException();
				                res *= 10;
				                res += c - '0';
				                c = read();
				            }
				            while (!isSpaceChar(c));
				                return res * sgn;
				        }
				        
				        public double nextDouble() 
				        {
				            int c = read();
				            while (isSpaceChar(c))
				                c = read();
				            int sgn = 1;
				            if (c == '-') 
				            {
				                sgn = -1;
				                c = read();
				            }
				            double res = 0;
				            while (!isSpaceChar(c) && c != '.') 
				            {
				                if (c == 'e' || c == 'E')
				                    return res * Math.pow(10, nextInt());
				                if (c < '0' || c > '9')
				                    throw new InputMismatchException();
				                res *= 10;
				                res += c - '0';
				                c = read();
				            }
				            if (c == '.') 
				            {
				                c = read();
				                double m = 1;
				                while (!isSpaceChar(c)) 
				                {
				                    if (c == 'e' || c == 'E')
				                        return res * Math.pow(10, nextInt());
				                    if (c < '0' || c > '9')
				                        throw new InputMismatchException();
				                    m /= 10;
				                    res += (c - '0') * m;
				                    c = read();
				                }
				            }
				            return res * sgn;
				        }
				        
				        public String readString() 
				        {
				            int c = read();
				            while (isSpaceChar(c))
				                c = read();
				            StringBuilder res = new StringBuilder();
				            do 
				            {
				                res.appendCodePoint(c);
				                c = read();
				            } 
				            while (!isSpaceChar(c));
				            
				            return res.toString();
				        }
				     
				        public boolean isSpaceChar(int c) 
				        {
				            if (filter != null)
				                return filter.isSpaceChar(c);
				            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
				        }
				     
				        public String next() 
				        {
				            return readString();
				        }
				        
				        public interface SpaceCharFilter 
				        {
				            public boolean isSpaceChar(int ch);
				        }
				    }
				     
				    public static void main(String args[]) throws Exception
				    {
				        new Thread(null, new Solution2(),"Solution2",1<<26).start();
				    }   
				    static long gcd(long a, long b) 
				    { 
				      if (b == 0) 
				        return a; 
				      return gcd(b, a % b);  
				    } 
				    static long lcm(long a,long b) {
				    	return (a*b)/gcd(a,b);
				    }
				    int maxn = 100005;
				    long MOD = 1000000007;
				    long prime = 29;
				    TreeMap<Integer,Long> adj2[];
				    ArrayList<Integer> adj[];
				    public void run() 
				    {
				    	InputReader sc = new InputReader(System.in);
						PrintWriter w = new PrintWriter(System.out);
						int n = sc.nextInt();
						adj2 = new TreeMap[n];
						adj = new ArrayList[n];
						for(int i = 0;i < n;i++) {
							adj2[i] = new TreeMap();
							adj[i] = new ArrayList();
						}
						for(int i = 0;i < n-1;i++) {
							int a = sc.nextInt()-1;
							int b = sc.nextInt()-1;
							adj[a].add(b);
							adj[b].add(a);
						}
						ans=  new long[n];
						level = new int[n];
						visited = new boolean[n];
						s = new SegTreeLazy(300005);
						bfs(0,n);
						int m = sc.nextInt();
						for(int i = 0;i < m;i++) {
							int a = sc.nextInt()-1;
							int b = sc.nextInt();
							long c = sc.nextLong();
							if(level[a] + b > n) {
								if(adj2[a].containsKey(n)) {
									adj2[a].put(n,adj2[a].get(n) + c);
								}else {
									adj2[a].put(n,c);
								}
							}else {
								if(adj2[a].containsKey(level[a]+ b)) {
									adj2[a].put(level[a] + b,adj2[a].get(level[a] + b) + c);
								}else {
									adj2[a].put(level[a] + b,c);
								}
							}
							
						}
						long[] freq = new long[300005];
						for(Integer key: adj2[0].keySet()) {
		    				s.update(0,freq.length-1,key,key,0,adj2[0].get(key));
						}
						dfs(0,freq);
						for(int i = 0;i < n;i++) {
							w.print(ans[i] + " ");
						}
						w.close();
				    }
				    int[] level;
				    void bfs(int a,int n) {
				    	Queue<Integer> q = new LinkedList();
				    	q.add(a);
				    	boolean[] visited = new boolean[n];
				    	level = new int[n];
				    	visited[a] = true;
				    	while(!q.isEmpty()) {
				    		int x = q.poll();
				    		Iterator<Integer> it = adj[x].iterator();
				    		while(it.hasNext()) {
				    			int z = it.next();
				    			if(!visited[z]) {
				    				q.add(z);
				    				level[z] = level[x] + 1;
				    				visited[z] = true;
				    			}
				    		}
				    	}
				    }
				    boolean[] visited;
				    long[] ans;
				    SegTreeLazy s;
				    void dfs(int a,long[] freq) {
				    	ans[a] = s.query(0,freq.length-1,level[a],freq.length-1,0);
				    	visited[a] = true;
				    	Iterator<Integer> it = adj[a].iterator();
				    	while(it.hasNext()) {
				    		int x = it.next();
				    		if(!visited[x]) {
				    			for(Integer p: adj2[x].keySet()) {
				    				s.update(0,freq.length-1,p,p,0,adj2[x].get(p));
				    			}
				    			dfs(x,freq);
				    			for(Integer p: adj2[x].keySet()) {
				    				s.update(0,freq.length-1,p,p,0,-adj2[x].get(p));
				    			}
				    		}
				    	}
				    }
				    static class SegTreeLazy{
						long[] segTree;
						long[] lazy;
						public SegTreeLazy(int n){
							segTree = new long[4*n];
							lazy = new long[4*n];
						}
						void build(int l,int r,int pos,int[] arr) {
							if(l == r) {
								segTree[pos] = arr[l];
								return;
							}
							int mid = (l + r)/2;
							build(l, mid, 2*pos+1, arr);
							build(mid+1, r, 2*pos+2, arr);
							segTree[pos] = segTree[2*pos+1] + segTree[2*pos+2];
						}
						void update(int l,int r,int start,int end,int pos,long val) {
							
							if(lazy[pos] != 0) {
								segTree[pos] += (r - l + 1) * lazy[pos];
								if(l != r) {
									lazy[2*pos+1] += lazy[pos];
									lazy[2*pos+2] += lazy[pos];
								}
								lazy[pos] = 0;
							}
							if(l > r || l > end || r < start) {
								return;
							}
							if(l >= start && r <= end) {
								segTree[pos] += (r - l + 1) * val;
								if(l != r) {
									lazy[2*pos+1] += val;
									lazy[2*pos+2] += val;
								}
								return;
							}
							int mid = (l + r)/2;
							update(l, mid, start, end, 2*pos+1, val);
							update(mid+1, r, start, end, 2*pos+2, val);
							segTree[pos] = segTree[2*pos+1] + segTree[2*pos+2];
						}
						long query(int l,int r,int start,int end,int pos) {
							if(lazy[pos] != 0) {
								segTree[pos] += (r - l + 1) * lazy[pos];
								if(l != r) {
									lazy[2*pos+1] += lazy[pos];
									lazy[2*pos+2] += lazy[pos];
								}
								lazy[pos] = 0;
							}
							if(l > r || l > end || r < start) {
								return 0;
							}
							if(l >= start && r <= end) {
								return segTree[pos];
							}
							int mid = (l + r)/2;
							long p1 = query(l, mid, start, end, 2*pos+1);
							long p2 = query(mid+1, r, start, end, 2*pos+2);
							return p1 + p2;
						}
					}
				    long[] fact = new long[100005];	
				    long nCr(int n,int r){ 
				    	long tmp1 = (fact[r] * fact[n-r]) % MOD;
				    	tmp1 = power(tmp1,MOD-2,MOD);
				    	long tmp2 = (fact[n] * tmp1) % MOD;
				    	return tmp2;
	 			    }
				    static long power(long a,long b,long mod) {
						long ans = 1;
						a = a % mod;
						while(b != 0) {
							if(b % 2 == 1) {
								ans = (ans * a) % mod;
							}
							a = (a * a) % mod;
							b = b/2;
						}
						return ans;
					}
				   void pre() {
					   fact[0] = 1;
					   for(int i = 1;i < 100005;i++) {
						   fact[i] = (fact[i-1] * i) % MOD;
					   }
				   }
				    class Pair implements Comparable<Pair>{
				        int a;
				        long b;
				        Pair(int a,long b){
				            this.b = b;
				            this.a = a;
				        }
				        public boolean equals(Object o) {
				            Pair p = (Pair)o;
				            return this.a == p.a && this.b == this.b;
				        }
				        public int hashCode(){
				            return Long.hashCode(a)*27 + Long.hashCode(b)*31;
				        }
				        public int compareTo(Pair p) {
				            return Long.compare(this.a,p.a);
				        }
				    }
				    
				}
