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.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

import static java.util.stream.Collectors.joining;

public final class VasyaAndTree {
    static class MyScanner {
        private BufferedReader br;
        private StringTokenizer st;

        MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

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

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

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

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

    static boolean [] visited;
    static List<Integer> [] neighbours;
    static FenwickTree tree;
    static FenwickTree treeNeg;
    static List<Long> score;
    // <value in node , depth size>
    static List<Map.Entry<Integer, Integer>> [] boosts;

    public static void main(String [] args) {
        MyScanner sc = new MyScanner();
        int vertices = sc.nextInt();

        score = new ArrayList<>(vertices+1);
        for (int i=0; i<=vertices; ++i) score.add(0L);
        visited = new boolean[vertices+1];
        neighbours = (List<Integer>[]) new ArrayList[vertices+1];
        for (int i=0; i<=vertices; ++i) neighbours[i] = new ArrayList<>();
        tree = new FenwickTree(vertices+1);
        treeNeg = new FenwickTree(vertices+1);
        boosts = (List<Map.Entry<Integer, Integer>>[]) new ArrayList[vertices+1];
        for (int i=0; i<=vertices; ++i) boosts[i] = new ArrayList<>();

        for (int i=1; i<vertices; ++i) {
            int x = sc.nextInt();
            int y = sc.nextInt();
            neighbours[x].add(y);
            neighbours[y].add(x);
        }

        int queries = sc.nextInt();
        for (int i=0; i<queries; ++i) {
            int vi = sc.nextInt();
            int di = sc.nextInt();  // subtree size
            int xi = sc.nextInt();  // value
            boosts[vi].add(new TreeMap.SimpleEntry<>(xi, di));
        }

        dfs(1, 1);

        System.out.println(score.stream().skip(1).map(Object::toString).collect(joining(" ")));

    }

    public static void dfs(int root, int height) {
        if (visited[root]) return;
        visited[root] = true;

        activateBoosts(root, height);
        score.set(root, tree.read(height) - treeNeg.read(height));
        for (int neighbour: neighbours[root]) {
            dfs(neighbour, height+1);
        }
        deactivateBoosts(root, height);
    }

    public static void activateBoosts(int root, int height) {
        for (Map.Entry<Integer, Integer> b: boosts[root]) {
            tree.update(height, b.getKey());
            treeNeg.update(height + b.getValue() + 1, b.getKey());
        }

    }

    public static void deactivateBoosts(int root, int height) {
        for (Map.Entry<Integer, Integer> b: boosts[root]) {
            treeNeg.update(height, b.getKey());
            tree.update(height + b.getValue() + 1, b.getKey());
        }

    }
}

class FenwickTree {
    private long[] array;

    public FenwickTree(int size) {
        array = new long[size + 1];
    }

    public long read(int idx) {
        long sum = 0;
        while (idx > 0) {
            sum += array[idx];
            idx -= (idx & (-idx));
        }
        return sum;
    }

    public long readSingle(int idx) {
        return read(idx) - read(idx - 1);
    }

    /**
     * Read from range [a, b] INCLUSIVE
     */
    public long readRange(int a, int b) {
        return read(a) - read(b-1);
    }

    public void scaleDown(int value) {
        for (int i=1; i<array.length; ++i) {
            array[i] = array[i] / value;
        }
    }

    public void scaleUp(int value) {
        for (int i=1; i<array.length; ++i) {
            array[i] = array[i] * value;
        }
    }

    public void update(int idx, long val) {
        while (idx < array.length) {
            array[idx] += val;
            idx += (idx & (-idx));
        }
    }
}
