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 Myclass {
     static ArrayList a[]=new ArrayList[3000001];
     static boolean visited[]=new boolean [300001];
     static long dp[][];
     static long[] ans=new long[300001];
     static ArrayList level[]=new ArrayList[300001];
     static int At[]=new int [300001];
     static int p[]=new int [300001];
     static int cur=0;
     static int st[]=new int[300001];
     static int finish[]=new int[300001];
     static int maxi=0;
     static void dfs(int n,int l) {
    	 visited[n]=true;
    	 st[n]=cur++;
    	 At[n]=l;
    	 level[l].add(new query(st[n],n,0L));
    	 maxi=Math.max(maxi, l);
    	 for(int i=0;i<a[n].size();i++) {
    		 int id=(int) a[n].get(i);
    		 if(!visited[id]) {
    			 p[id]=n;
    			 dfs(id,l+1);
    		 }
    	 }
    	 finish[n]=cur++;
     }
     static void dfs1(int n) {
    	 visited[n]=true;
    	 for(int i=0;i<a[n].size();i++) {
    		 int id=(int) a[n].get(i);
    		 if(!visited[id]) {
    			 ans[id]+=ans[n];
    			 dfs1(id);
    		 }
    	 }
     }
     public static void main(String[]args)
    {
        InputReader in=new InputReader(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int n=in.nextInt();
       	for(int i=0;i<=300000;i++) {
       		a[i]=new ArrayList<Integer>();
       		level[i]=new ArrayList<query>();
       	}
       	for(int i=0;i<n-1;i++) {
       		int x=in.nextInt();
       		int y=in.nextInt();
       		a[x].add(y);
       		a[y].add(x);
       	}
       	dfs(1,0);
       	dp=new long[maxi+1][];
       	for(int i=0;i<=maxi;i++) {
       		dp[i]=new long[level[i].size()+1];
       	}
       	Arrays.fill(visited, false);
       	int q=in.nextInt();
       	while(q-->0) {
       		int v=in.nextInt();
       		long d=in.nextLong();
       		long x=in.nextLong();
       		int take=(int) Math.min(maxi, At[v]+d);
       		int start=0;
       		ans[v]+=x;
       		int end=level[take].size()-1;
       		int ans=-1;
       		while(start<=end) {
       			int mid=(start+end)/2;
       			query p=(query) level[take].get(mid);
       			if(p.x>=st[v]) {
       				ans=mid;
       				end=mid-1;
       			}
       			else
       				start=mid+1;
       		}
       		start=0;
       		end=level[take].size()-1;
       		int ans1=-1;
       		while(start<=end) {
       			int mid=(start+end)/2;
       			query p=(query) level[take].get(mid);
       			if(p.x<=finish[v]) {
       				ans1=mid;
       				start=mid+1;
       			}
       			else
       				end=mid-1;
       		}
       		if(ans!=-1) {
       			dp[take][ans]+=x;
       			dp[take][ans1+1]-=x;
       		}
       	}
       	for(int i=0;i<=maxi;i++) {
       		for(int j=0;j<level[i].size();j++) {
       			if(j!=0)
       			dp[i][j]+=dp[i][j-1];
       			query val=(query) level[i].get(j);
       			for(int k=0;k<a[val.y].size();k++) {
       				int id=(int) a[val.y].get(k);
       				if(id!=p[val.y]) {
       					ans[id]-=dp[i][j];
       				}
       			}
       		}
       	}
       	dfs1(1);
       	for(int i=1;i<=n;i++)
       		pw.print(ans[i]+" ");
        pw.flush();
        pw.close();
 
    }
    private static void debug(Object... o) {
        System.out.println(Arrays.deepToString(o));
    }
   static class InputReader 
        {
        private final InputStream stream;
        private final byte[] buf = new byte[8192];
        private int curChar, snumChars;
        private SpaceCharFilter filter;
 
        public InputReader(InputStream stream) 
        { 
            this.stream = stream;
        }
        public int snext() 
        {
            if (snumChars == -1)
                throw new InputMismatchException();
            if (curChar >= snumChars) 
            {
                curChar = 0;
                try 
                {
                    snumChars = stream.read(buf);
                } 
                
                catch (IOException e) 
                {
                    throw new InputMismatchException();
                }
                
                if (snumChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }
 
        public int nextInt() 
        {
            int c = snext();
            while (isSpaceChar(c)) 
            {
                c = snext();
            }
            int sgn = 1;
            if (c == '-')
            {
                sgn = -1;
                c = snext();
            }
            int res = 0;
            do 
            {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = snext();
            } while (!isSpaceChar(c));
            return res * sgn;
        }
 
        public long nextLong()
        {
            int c = snext();
            while (isSpaceChar(c)) 
            {
                c = snext();
            }
            int sgn = 1;
            if (c == '-') 
            {
                sgn = -1;
                c = snext();
            }
            long res = 0;
            do 
            {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = snext();
            } while (!isSpaceChar(c));
            return res * sgn;
        }
 
        public int[] nextIntArray(int n) 
        {
            int a[] = new int[n];
            for (int i = 0; i < n; i++) 
            {
                a[i] = nextInt();
            }
            return a;
        }
        static class tri implements Comparable<tri> {
            int p, c, l;
 
            tri(int p, int c, int l) {
                this.p = p;
                this.c = c;
                this.l = l;
            }
 
            public int compareTo(tri o) {
                return Integer.compare(l, o.l);
            }
        }
 
        public String readString()
        {
            int c = snext();
            while (isSpaceChar(c)) 
            {
                c = snext();
            }
            StringBuilder res = new StringBuilder();
            do 
            {
                res.appendCodePoint(c);
                c = snext();
            } while (!isSpaceChar(c));
            return res.toString();
        }
 
        public String nextLine() 
        {
            int c = snext();
            while (isSpaceChar(c))
                c = snext();
            StringBuilder res = new StringBuilder();
            do 
            {
                res.appendCodePoint(c);
                c = snext();
            } while (!isEndOfLine(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;
        }
 
        private boolean isEndOfLine(int c) 
        {
            return c == '\n' || c == '\r' || c == -1;
        }
 
        public interface SpaceCharFilter
        {
            public boolean isSpaceChar(int ch);
        }
    }
   public static long modularExponentiation(long x,long n,long M)
   {
       long result=1;
       while(n>0)
       {
           if(n % 2 ==1)
               result=(result%M * x%M)%M;
           x=(x%M * x%M)%M;
           n=n/2;
       }
       return result;
   }
   
   public static long modInverse(int A,int M)
   {
       return modularExponentiation(A,M-2,M);
   }
   
   public static long modInverse(long A,long M)
   {
       return modularExponentiation(A,M-2,M);
   }
    static class pair implements Comparable<pair>{
        Integer x;
        Long y;

        pair(int x,long l){
            this.x=x;
            this.y=l;
        }
        
        public int compareTo(pair o) {
                int result = x.compareTo(o.x);
                if(result==0)
                    result = y.compareTo(o.y);
                
            return result;
            }  
         public String toString(){
            return (x+" "+y);
        }
  }
    public static long GCD(long a,long b)
    {
        if(b==0)
            return a;
        else
            return GCD(b,a%b);
    }
    public static long[] shuffle(long[] a, Random gen){ 
        for(int i = 0, n = a.length;i < n;i++){ 
            int ind = gen.nextInt(n-i)+i; 
            long d = a[i]; 
            a[i] = a[ind]; 
            a[ind] = d; 
        } 
        return a; 
    }
  static class query{
      Integer x;
      Integer y;
      Long z;
      query(int x,int y,long z){
          this.x=x;
          this.y=y;
          this.z=z;
      }
      
	public String toString() {
    	  return ((x+" "+y+" "+z));
      }
  }
    
}
 