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.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStream;

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

    static class TaskE {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            TaskE.Node[] nodes = new TaskE.Node[n];
            for (int i = 0; i < n; ++i)
                nodes[i] = new TaskE.Node();

            for (int i = 0; i < n - 1; ++i) {
                TaskE.Node u = nodes[in.nextInt() - 1];
                TaskE.Node v = nodes[in.nextInt() - 1];
                u.adj.add(v);
                v.adj.add(u);
            }

            int m = in.nextInt();
            for (int i = 0; i < m; ++i) {
                TaskE.Node u = nodes[in.nextInt() - 1];
                u.transforms.add(new Pair<>(in.nextInt(), in.nextInt()));
            }

            BIT tree = new BIT(n);
            traverse(nodes[0], 1, null, tree);

            for (TaskE.Node node : nodes)
                out.print(node.answer + " ");
            out.println();
        }

        private void traverse(TaskE.Node node, int level, TaskE.Node parent, BIT tree) {
            for (Pair<Integer, Integer> transform : node.transforms) {
                int depth = transform.first;
                int increase = transform.second;
                tree.update(Math.min(tree.capacity(), level + depth), increase);
            }

            node.answer = tree.read(level, tree.capacity());
            for (TaskE.Node child : node.adj) {
                if (child != parent)
                    traverse(child, level + 1, node, tree);
            }

            for (Pair<Integer, Integer> transform : node.transforms) {
                int depth = transform.first;
                int increase = transform.second;
                tree.update(Math.min(tree.capacity(), level + depth), -increase);
            }
        }

        static class Node {
            long answer;
            List<TaskE.Node> adj = new ArrayList<>();
            List<Pair<Integer, Integer>> transforms = new ArrayList<>();

        }

        public class BIT {
            private int capacity;
            private long[] data;

            public BIT(int capacity) {
                this.capacity = capacity;
                data = new long[capacity + 1];
            }

            public long read(int index) {
                long result = 0;
                while (index > 0) {
                    result += data[index];
                    index -= (index & -index);
                }
                return result;
            }

            public long read(int low, int high) {
                return read(high) - read(low - 1);
            }

            public void update(int index, int value) {
                while (index <= capacity) {
                    data[index] += value;
                    index += (index & -index);
                }
            }

            public int capacity() {
                return capacity;
            }

        }

    }

    static class Pair<U extends Comparable<U>, V extends Comparable<V>> implements Comparable<Pair<U, V>> {
        public U first;
        public V second;

        public Pair(U first, V second) {
            this.first = first;
            this.second = second;
        }

        public int hashCode() {
            return (first == null ? 0 : first.hashCode() * 31) + (second == null ? 0 : second.hashCode());
        }

        public boolean equals(Object o) {
            if (this == o)
                return true;
            if (o == null || getClass() != o.getClass())
                return false;
            Pair<U, V> p = (Pair<U, V>) o;
            return (first == null ? p.first == null : first.equals(p.first)) && (second == null ? p.second == null : second.equals(p.second));
        }

        public int compareTo(Pair<U, V> b) {
            int cmpU = first.compareTo(b.first);
            return cmpU != 0 ? cmpU : second.compareTo(b.second);
        }

    }

    static class InputReader {
        private BufferedReader reader;
        private StringTokenizer tokenizer;
        private static final int BUFFER_SIZE = 32768;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(
                    new InputStreamReader(stream), BUFFER_SIZE);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}

