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.lang.*;
import java.math.*;
import java.util.*;
import java.io.*;
public class Main {
class Node implements Comparable<Node>{
    int v;
    int level;
    public Node(int v,int depth){
        this.v=v;
        this.level=depth;
    }
    public int compareTo(Node c){
        return Integer.compare(this.level,c.level);

    }
}
    void solve() {
         n=ni();
         g=new ArrayList[n+1];
         for(int i=1;i<=n;i++) g[i]=new ArrayList<>();
         for(int i=1;i<n;i++){
             int u=ni(),v=ni();
             g[u].add(v); g[v].add(u);
         }
         st=new int[n+1];
        ed=new int[n+1];
        level=new int[n+1];
        a=new int[n+1];
        dfs(1,-1,0);
        tree=new Node[4*n+1][];
        val=new long[4*n+1][];
        build(1,1,n);
        int q=ni();
        while(q-->0){
            int v=ni(),d=ni(),x=ni();
            update(1,st[v],ed[v],1,n,d,x,v);
        }
        ans=new long[n+1];
        go(1,1,n);
        for(int i=1;i<=n;i++) pw.print(ans[i]+" ");
        pw.println("");


    }
    int n;
    int st[],ed[];
    int cc=0;
    ArrayList<Integer> g[];
    int level[];
    int a[];
    void dfs(int v,int pr,int l){
        level[v]=l;
        st[v]=++cc;
        a[cc]=v;
        for(int u : g[v]){
            if(u!=pr) dfs(u,v,l+1);
        }
        ed[v]=cc;
    }
    Node tree[][];
    long val[][];
    long ans[];
    void go(int id,int l,int r){
        for(int i=1;i<tree[id].length;i++) val[id][i]+=val[id][i-1];
        for(int i=0;i<tree[id].length;i++){
            ans[a[tree[id][i].v]]+=val[id][i];
        }
        if(l==r)
            return;

            int mid=(l+r)>>1;
            go(2*id,l,mid);
            go(2*id+1,mid+1,r);

    }
    void update(int id,int x,int y,int l,int r,int d,int dx,int v){
        if(r<x || l>y) return;
        if(x<=l && r<=y){
            int ll=0,rr=tree[id].length-1;
            int idx=-1;
            while(ll<=rr){
                int mid=(ll+rr)>>1;
                if(tree[id][mid].level-level[v]<=d){
                    idx=mid;
                    ll=mid+1;
                }else rr=mid-1;
            }

            val[id][0]+=dx;
            if(idx+1<tree[id].length) val[id][idx+1]-=dx;
            return;

        }
        int mid=(l+r)>>1;
        update(2*id,x,y,l,mid,d,dx,v);
        update(2*id+1,x,y,mid+1,r,d,dx,v);
    }
    void build(int id,int l,int r){
        if(l==r){
            tree[id]=new Node[1];
            val[id]=new long[1];
            tree[id][0]=new Node(l,level[a[l]]);

        }else {
            int mid=(l+r)>>1;
            build(2*id,l,mid);
            build(2*id+1,mid+1,r);
            merge(id);
        }
    }
    void merge(int id){
        int sz1=tree[2*id].length,sz2=tree[2*id+1].length;
        int id1=0,id2=0,idx=0;
        tree[id]=new Node[sz1+sz2];
        val[id]=new long[sz1+sz2];

        while(id1<sz1 && id2<sz2){
            if(tree[2*id][id1].level<tree[2*id+1][id2].level){
                tree[id][idx++]=tree[2*id][id1++];
            }else tree[id][idx++]=tree[2*id+1][id2++];
            //if(id==2) pw.println(id1+" "+id2+" "+sz1+" "+sz2);
        }
        while(id1<sz1) tree[id][idx++]=tree[2*id][id1++];
        while(id2<sz2) tree[id][idx++]=tree[2*id+1][id2++];

    }



    long M =(long)1e9+7;
    InputStream is;
    PrintWriter pw;
    String INPUT = "";

    void run() throws Exception {
        is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());
        pw = new PrintWriter(System.out);
        long s = System.currentTimeMillis();
        solve();
        pw.flush();
        if (!INPUT.isEmpty()) tr(System.currentTimeMillis() - s + "ms");

    }

    public static void main(String[] args) throws Exception {
        new Main().run();
    }

    private byte[] inbuf = new byte[1024];
    public int lenbuf = 0, ptrbuf = 0;

    private int readByte() {
        if (lenbuf == -1) throw new InputMismatchException();
        if (ptrbuf >= lenbuf) {
            ptrbuf = 0;
            try {
                lenbuf = is.read(inbuf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (lenbuf <= 0) return -1;
        }
        return inbuf[ptrbuf++];
    }

    private boolean isSpaceChar(int c) {
        return !(c >= 33 && c <= 126);
    }

    private int skip() {
        int b;
        while ((b = readByte()) != -1 && isSpaceChar(b)) ;
        return b;
    }

    private double nd() {
        return Double.parseDouble(ns());
    }

    private char nc() {
        return (char) skip();
    }

    private String ns() {
        int b = skip();
        StringBuilder sb = new StringBuilder();
        while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    private char[] ns(int n) {
        char[] buf = new char[n];
        int b = skip(), p = 0;
        while (p < n && !(isSpaceChar(b))) {
            buf[p++] = (char) b;
            b = readByte();
        }
        return n == p ? buf : Arrays.copyOf(buf, p);
    }

    private char[][] nm(int n, int m) {
        char[][] map = new char[n][];
        for (int i = 0; i < n; i++) map[i] = ns(m);
        return map;
    }

    private int[] na(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) a[i] = ni();
        return a;
    }

    private int ni() {
        int num = 0, b;
        boolean minus = false;
        while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
        if (b == '-') {
            minus = true;
            b = readByte();
        }

        while (true) {
            if (b >= '0' && b <= '9') {
                num = num * 10 + (b - '0');
            } else {
                return minus ? -num : num;
            }
            b = readByte();
        }
    }

    private long nl() {
        long num = 0;
        int b;
        boolean minus = false;
        while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
        if (b == '-') {
            minus = true;
            b = readByte();
        }

        while (true) {
            if (b >= '0' && b <= '9') {
                num = num * 10 + (b - '0');
            } else {
                return minus ? -num : num;
            }
            b = readByte();
        }
    }

    private boolean oj = System.getProperty("ONLINE_JUDGE") != null;

    private void tr(Object... o) {
        if (INPUT.length() > 0) System.out.println(Arrays.deepToString(o));
    }

}