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.awt.*;
import java.io.*;
import java.rmi.server.ExportException;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.StringTokenizer;

public class CF_1076E {
    static ArrayList<ArrayList<Point>> upds;
    static ArrayList<ArrayList<Integer>> adj;
    static long[] ret;

    public static void main(String args[]) throws Exception {
        BufferedScanner in = new BufferedScanner(new InputStreamReader(System.in));
        PrintStream out = new PrintStream(new BufferedOutputStream(System.out));

        int n = in.nextInt();

        ret = new long[n];

        adj = new ArrayList<>();
        upds = new ArrayList<>();
        for (int i = 0; i < n; i++) adj.add(new ArrayList<>());
        for (int i = 0; i < n; i++) upds.add(new ArrayList<>());

        for (int i = 0; i < n - 1; i++) {
            int u = in.nextInt() - 1, v = in.nextInt() - 1;

            adj.get(u).add(v);
            adj.get(v).add(u);
        }

        int m = in.nextInt();
        for (int i = 0; i < m; i++) {
            upds.get(in.nextInt() - 1).add(new Point(in.nextInt(), in.nextInt()));
        }

        dfs(0, -1, 0, new BIT());

        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++) {
            sb.append(ret[i]);
            sb.append(' ');
        }
        out.println(sb.toString());

        out.close();
        in.close();
    }

    static void dfs(int curr, int p, int d, BIT cnts) {
        for (Point upd : upds.get(curr)) {
            cnts.update(d, upd.y);
            cnts.update(d + upd.x + 1, -upd.y);
        }
        for (Integer v : adj.get(curr)) {
            if (v == p) continue;
            dfs(v, curr, d + 1, cnts);
        }
        ret[curr] = cnts.query(d);
        for (Point upd : upds.get(curr)) {
            cnts.update(d, -upd.y);
            cnts.update(d + upd.x + 1, upd.y);
        }
    }

    static class BIT {
        public static int SIZE = 500000;
        public long[] data = new long[SIZE + 1];

        public void update(int n, int k) {
            for (int i = n + 1; i < data.length; i += -i & i)
                data[i] += k;
        }

        public long query(int n) {
            long ret = 0;
            for (int i = n + 1; i > 0; i -= -i & i)
                ret += data[i];

            return ret;
        }

        public long query(int a, int b) {
            return query(b) - query(a - 1);
        }
    }

    static class BufferedScanner {
        private BufferedReader in;
        private StringTokenizer st;

        BufferedScanner(Reader in) throws IOException {
            this.in = new BufferedReader(in);
            st = new StringTokenizer(this.in.readLine());
        }

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

        String next() throws IOException {
            if (!st.hasMoreElements()) st = new StringTokenizer(in.readLine());

            return st.nextToken();
        }

        void close() throws IOException {
            in.close();
        }

    }

}
