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.util.*;
import java.io.*; 
import java.text.*;
//Solution Credits: Taranpreet Singh
public class Main{
    //SOLUTION BEGIN
    void solve(int TC) throws Exception{
        int n = ni();
        int[][] g = new int[n][];int[][] edge = new int[n-1][];int[] cnt = new int[n];
        for(int i = 0; i< n-1; i++){
            edge[i] = new int[]{ni()-1, ni()-1};
            cnt[edge[i][0]]++;cnt[edge[i][1]]++;
        }
        HashMap<Long, Long>[] map = new HashMap[n];
        for(int i = 0; i< n; i++){g[i] = new int[cnt[i]];map[i] = new HashMap<>();}
        for(int i = 0; i< n-1; i++){
            g[edge[i][0]][--cnt[edge[i][0]]] = edge[i][1];
            g[edge[i][1]][--cnt[edge[i][1]]] = edge[i][0];
        }
        for(int m = ni(); m>0; m--){
            int v = ni()-1;
            long d = nl(), x = nl();
            map[v].put(d, map[v].getOrDefault(d, 0l)+x);
        }
        long[] ans = new long[n];
        int[] dep = new int[n];
        dep(g, dep, 0, -1);
        t = new SegTree(n);                 
        dfs(g, map, dep, ans, 0, -1);
        for(int i = 0; i< n; i++)p(ans[i]+" " );
    }
    SegTree t;
    void dep(int[][] g,int[] dep, int u, int p){
        for(int v:g[u]){
            if(v==p)continue;
            dep[v] = dep[u]+1;
            dep(g,dep,v,u);
        }
    }
    void dfs(int[][] g,HashMap<Long, Long>[] map, int[] dep, long[] ans, int u, int p){
        for(Map.Entry<Long, Long> e:map[u].entrySet())
            t.modify(dep[u], (int)Math.min(dep[u]+e.getKey(), g.length-1)+1, e.getValue());
        ans[u] = t.query(dep[u]);
        for(int v:g[u]){
            if(v==p)continue;
            dfs(g, map, dep, ans, v, u);
        }
        for(Map.Entry<Long, Long> e:map[u].entrySet())t.modify(dep[u], (int)Math.min(dep[u]+e.getKey(), g.length-1)+1, -e.getValue());
    }
    class SegTree{
        int m=1;
        long[] t;
        public SegTree(int n){
            while(m<n)m<<=1;
            t = new long[m<<1];
        }
        void modify(int l, int r, long value) {
            for (l += m, r += m; l < r; l >>= 1, r >>= 1) {
                if ((l&1)==1) t[l++] += value;
                if ((r&1)==1) t[--r] += value;
            }
        }
        long query(int p) {
            long res = 0;
            for (p += m; p > 0; p >>= 1) res += t[p];
            return res;
        }
    }
    //SOLUTION END
    long mod = (long)1e9+7, IINF = (long)1e17;
    final int MAX = (int)1e3+1, INF = (int)2e9, root = 3;
    DecimalFormat df = new DecimalFormat("0.000000000");
    double PI = 3.1415926535897932384626433832792884197169399375105820974944, eps = 1e-8;
    static boolean multipleTC = false, memory = false;
    FastReader in;PrintWriter out;
    void run() throws Exception{
        in = new FastReader();
        out = new PrintWriter(System.out);
        int T = (multipleTC)?ni():1;
        //Solution Credits: Taranpreet Singh
        for(int i = 1; i<= T; i++)solve(i);
        out.flush();
        out.close();
    }
    public static void main(String[] args) throws Exception{
        if(memory)new Thread(null, new Runnable() {public void run(){try{new Main().run();}catch(Exception e){e.printStackTrace();}}}, "1", 1 << 28).start();
        else new Main().run();
    }
    long gcd(long a, long b){return (b==0)?a:gcd(b,a%b);}
    int gcd(int a, int b){return (b==0)?a:gcd(b,a%b);}
    int bit(long n){return (n==0)?0:(1+bit(n&(n-1)));}
    void p(Object o){out.print(o);}
    void pn(Object o){out.println(o);}
    void pni(Object o){out.println(o);out.flush();}
    String n(){return in.next();}
    String nln(){return in.nextLine();}
    int ni(){return Integer.parseInt(in.next());}
    long nl(){return Long.parseLong(in.next());}
    double nd(){return Double.parseDouble(in.next());}

    class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastReader(String s) throws Exception{
            br = new BufferedReader(new FileReader(s));
        }

        String next(){
            while (st == null || !st.hasMoreElements()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (IOException  e){
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine(){
            String str = "";
            try{    
                str = br.readLine();
            }catch (IOException e){
                e.printStackTrace();
            }   
            return str;
        }
    }
}  