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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.ArrayList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author caoash
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        EVasyaAndATree solver = new EVasyaAndATree();
        solver.solve(1, in, out);
        out.close();
    }

    static class EVasyaAndATree {
        static int n;
        ArrayList<Integer>[] adj;
        ArrayList<Pair>[] queries;
        static BIT depSum;
        static int[] depth;
        static int maxDepth;
        static long[] ret;

        public void solve(int testNumber, FastScanner br, PrintWriter pw) {
            maxDepth = 0;
            n = br.nextInt();
            depth = new int[n];
            ret = new long[n];
            adj = br.nextTree(n);
            queries = new ArrayList[n];
            int m = br.nextInt();
            for (int i = 0; i < n; i++) {
                queries[i] = new ArrayList<Pair>();
            }
            for (int i = 0; i < m; i++) {
                int v = br.nextInt();
                int d = br.nextInt();
                long x = br.nextLong();
                v--;
                queries[v].add(new Pair(d, x));
            }
            dfsForDepth(0, -1);
            depSum = new BIT(maxDepth + 5);
            dfsForAns(0, -1);
            for (int i = 0; i < n; i++) {
                pw.print(ret[i] + " ");
            }
//        int[] a = {1,2,3,4};
//        BIT bit_a = new BIT(a.length+1);
//        for(int i = 0; i < a.length; i++){
//            bit_a.rangeUpdate(i,i,a[i]);
//        }
//        pw.println("bita query: " + bit_a.query(3));
//        bit_a.rangeUpdate(0,2,3);
            pw.close();
        }

        public void dfsForDepth(int v, int pV) {
            for (int e : adj[v]) {
                if (e == pV) {
                    continue;
                }
                depth[e] = depth[v] + 1;
                maxDepth = Math.max(maxDepth, depth[e]);
                dfsForDepth(e, v);
            }
        }

        public void dfsForAns(int v, int pV) {
            for (Pair q : queries[v]) {
                depSum.rangeUpdate(depth[v], Math.min(maxDepth, depth[v] + q.f), q.s);
            }
            long ans = depSum.query(depth[v]);
            ret[v] = ans;
            for (int e : adj[v]) {
                if (e == pV) {
                    continue;
                }
                dfsForAns(e, v);
            }
            for (Pair q : queries[v]) {
                depSum.rangeUpdate(depth[v], Math.min(maxDepth, depth[v] + q.f), -q.s);
            }
        }

        public class Pair {
            int f;
            long s;

            public Pair(int f, long s) {
                this.f = f;
                this.s = s;
            }

        }

        public class BIT {
            int n;
            long[] bit;

            public BIT(int n) {
                this.n = n;
                bit = new long[n + 5];
            }

            public void add(int i, long val) {
                for (++i; i < n; i += i & -i) {
                    bit[i] += val;
                }
            }

            public void rangeUpdate(int l, int r, long val) {
                add(l, val);
                add(r + 1, -val);
            }

            public long query(int i) {
                long ret = 0;
                for (++i; i > 0; i -= i & -i) {
                    ret += bit[i];
                }
                return ret;
            }

        }

    }

    static class FastScanner {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastScanner.SpaceCharFilter filter;

        public FastScanner(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 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 boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public ArrayList<Integer>[] nextGraph(int n, int m) {
            ArrayList<Integer>[] adj = new ArrayList[n];
            for (int i = 0; i < n; i++) {
                adj[i] = new ArrayList<Integer>();
            }
            for (int i = 0; i < m; i++) {
                int u = nextInt();
                int v = nextInt();
                u--;
                v--;
                adj[u].add(v);
                adj[v].add(u);
            }
            return adj;
        }

        public ArrayList<Integer>[] nextTree(int n) {
            return nextGraph(n, n - 1);
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}

