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.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.util.HashMap;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.TreeMap;
import java.util.Map;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.InputStream;

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

    static class _1076E {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int n = in.nextInt();

            List[] g = new List[n];

            in.readUndirectedGraph(g, n, n - 1, 1);

            int m = in.nextInt();

            DfsSubtree sub = new DfsSubtree(g);
            sub.dfs(0, -1, 0, 0);

            HashMap<Integer, TreeMap<Integer, Long>> hm = sub.hm;

            for (int i = 0; i < m; i++) {
                int v = in.nextInt();
                v--;

                int d = in.nextInt();

                long x = in.nextInt();

                int ch = sub.h[v];

                int st = sub.subStart[v];

                hm.get(ch).merge(st, x, (a, b) -> a + b);

                Integer ceil = hm.get(ch).ceilingKey(st + 1);

                if (ceil != null) {
                    hm.get(ch).merge(ceil, -x, (a, b) -> a + b);
                }

                int nh = ch + d + 1;

                if (!hm.containsKey(nh))
                    continue;

                TreeMap<Integer, Long> cm = hm.get(nh);

                Integer ceil1 = cm.ceilingKey(st);
                Integer ceil2 = cm.ceilingKey(sub.subEnd[v] + 1);

                if (ceil1 != null) {
                    cm.merge(ceil1, -x, (a, b) -> a + b);

                    if (ceil2 != null) {
                        cm.merge(ceil2, x, (a, b) -> a + b);
                    }
                }
            }

            for (int h : hm.keySet()) {
                long pv = 0;
                TreeMap<Integer, Long> cm = hm.get(h);
                for (int val : cm.keySet()) {
                    cm.merge(val, pv, (a, b) -> a + b);
                    pv = cm.get(val);
                }
            }

            long[] ans = new long[n];

            dfs(0, -1, ans, sub, g);

            for (int i = 0; i < n; i++) {
                out.print(ans[i] + " ");
            }
        }

        void dfs(int u, int p, long[] ans, DfsSubtree sub, List[] g) {
            if (p == -1) {
                ans[u] = sub.hm.get(sub.h[u]).get(sub.subStart[u]);
            } else {
                ans[u] = sub.hm.get(sub.h[u]).get(sub.subStart[u]) + ans[p];
            }

            for (int v : (List<Integer>) g[u]) {
                if (v != p) {
                    dfs(v, u, ans, sub, g);
                }
            }
        }

        class DfsSubtree {
            int[] dfsOrder;
            int[] h;
            int[] subStart;
            int[] subEnd;
            int n;
            List[] g;
            HashMap<Integer, TreeMap<Integer, Long>> hm = new HashMap<>();

            public DfsSubtree(List[] g) {
                this.n = g.length;
                this.g = g;
                this.dfsOrder = new int[n];
                this.h = new int[n];
                this.subStart = new int[n];
                this.subEnd = new int[n];
            }

            int dfs(int u, int p, int st, int ch) {
                dfsOrder[st] = u;
                h[u] = ch; // Store as per per question
                subStart[u] = st;

                if (!hm.containsKey(ch)) {
                    hm.put(ch, new TreeMap<>());
                }

                hm.get(ch).put(st, 0l);

                st++;

                for (int i = 0; i < g[u].size(); i++) {
                    int v = (int) g[u].get(i);

                    if (v == p)
                        continue;

                    st = dfs(v, u, st, ch + 1);
                }

                subEnd[u] = st - 1;

                return st;
            }

        }

    }

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

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

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

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

        public void readUndirectedGraph(List[] g, int numOfVertices, int numOfEdges, int offset) {
            for (int i = 0; i < numOfVertices; i++) {
                g[i] = new ArrayList();
            }

            for (int i = 0; i < numOfEdges; i++) {
                int u = nextInt() - offset;
                int v = nextInt() - offset;

                g[u].add(v);
                g[v].add(u);
            }
        }

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

        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void print(Object... objects) {
            for (int i = 0; i < objects.length; i++) {
                if (i != 0) {
                    writer.print(' ');
                }
                writer.print(objects[i]);
            }
        }

        public void close() {
            writer.close();
        }

    }
}

