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.

/**
 * Date: 13 Nov, 2018
 * Link:
 *
 * @author Prasad-Chaudhari
 * @linkedIn: https://www.linkedin.com/in/prasad-chaudhari-841655a6/
 * @git: https://github.com/Prasad-Chaudhari
 */
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.Arrays;
import java.util.Stack;

public class newProgram9 {

    public static void main(String[] args) throws IOException {
        // TODO code application logic here
        FastIO in = new FastIO();
        int n = in.ni();
        int adja[][] = in.gg(n, n - 1);
        int m = in.ni();
        Data d[] = new Data[m];
        int count[] = new int[n + 1];
        for (int i = 0; i < m; i++) {
            d[i] = new Data(in.ni(), in.ni(), in.ni());
            count[d[i].a]++;
        }
        Data curr[][] = new Data[n + 1][];
        for (int i = 0; i <= n; i++) {
            curr[i] = new Data[count[i]];
        }
        for (int i = 0; i < m; i++) {
            curr[d[i].a][--count[d[i].a]] = d[i];
        }
//        for (int i = 1; i <= n; i++) {
//            for (Data dd : curr[i]) {
//                System.out.println(dd.a + " " + dd.b + " " + dd.c);
//            }
//        }
        long delete[] = new long[n + 1];
        int level[] = new int[n + 1];
        for (int i = 0; i <= n; i++) {
            count[i] = adja[i].length - 1;
        }
        count[1]++;
        Stack<Integer> st = new Stack<>();
        boolean b[] = new boolean[n + 1];
        b[1] = true;
        st.push(1);
        long acc = 0;
        long value[] = new long[n + 1];
        dfs(st, delete, level, value, 0, b, curr, adja);
        for (int i = 1; i <= n; i++) {
            in.println(value[i] + "");
        }
        in.bw.flush();;
    }

    private static void dfs(Stack<Integer> st, long[] delete, int[] level, long[] value, long acc, boolean[] b, Data curr[][], int adja[][]) {
        if (st.isEmpty()) {
            return;
        }
        int root = st.pop();
        for (Data item : curr[root]) {
            acc += item.c;
            if (level[root] + item.b + 1 < delete.length - 1) {
                delete[level[root] + item.b + 1] += item.c;
            }
        }
//        System.out.println(root);
//        System.out.println(acc);
//        for (long i : delete) {
//            System.out.print(i + " ");
//        }
//        System.out.println("");
        value[root] = acc - delete[level[root]];
        for (int i : adja[root]) {
            if (!b[i]) {
                b[i] = true;
                st.push(i);
                level[i] = level[root] + 1;
                dfs(st, delete, level, value, acc - delete[level[root]], b, curr, adja);
            }
        }
        for (Data item : curr[root]) {
            if (level[root] + item.b + 1 < delete.length - 1) {
                delete[level[root] + item.b + 1] -= item.c;
            }
        }
    }

    static class FastIO {

        private final BufferedReader br;
        private final BufferedWriter bw;
        private String s[];
        private int index;
        private StringBuilder sb;

        public FastIO() throws IOException {
            br = new BufferedReader(new InputStreamReader(System.in));
            bw = new BufferedWriter(new OutputStreamWriter(System.out, "UTF-8"));
            s = br.readLine().split(" ");
            sb = new StringBuilder();
            index = 0;
        }

        public int ni() throws IOException {
            return Integer.parseInt(nextToken());
        }

        public double nd() throws IOException {
            return Double.parseDouble(nextToken());
        }

        public long nl() throws IOException {
            return Long.parseLong(nextToken());
        }

        public String next() throws IOException {
            return nextToken();
        }

        public String nli() throws IOException {
            try {
                return br.readLine();
            } catch (IOException ex) {

            }
            return null;
        }

        public int[] gia(int n) throws IOException {
            int a[] = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }

        public int[] gia(int n, int start, int end) throws IOException {
            validate(n, start, end);
            int a[] = new int[n];
            for (int i = start; i < end; i++) {
                a[i] = ni();
            }
            return a;
        }

        public double[] gda(int n) throws IOException {
            double a[] = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }

        public double[] gda(int n, int start, int end) throws IOException {
            validate(n, start, end);
            double a[] = new double[n];
            for (int i = start; i < end; i++) {
                a[i] = nd();
            }
            return a;
        }

        public long[] gla(int n) throws IOException {
            long a[] = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }

        public long[] gla(int n, int start, int end) throws IOException {
            validate(n, start, end);
            long a[] = new long[n];
            for (int i = start; i < end; i++) {
                a[i] = nl();
            }
            return a;
        }

        public int[][] gg(int n, int m) throws IOException {
            int adja[][] = new int[n + 1][];
            int from[] = new int[m];
            int to[] = new int[m];
            int count[] = new int[n + 1];
            for (int i = 0; i < m; i++) {
                from[i] = ni();
                to[i] = ni();
                count[from[i]]++;
                count[to[i]]++;
            }
            for (int i = 0; i <= n; i++) {
                adja[i] = new int[count[i]];
            }
            for (int i = 0; i < m; i++) {
                adja[from[i]][--count[from[i]]] = to[i];
                adja[to[i]][--count[to[i]]] = from[i];
            }
            return adja;
        }

        public void print(String s) throws IOException {
            bw.write(s);
        }

        public void println(String s) throws IOException {
            bw.write(s);
            bw.newLine();
        }

        private String nextToken() throws IndexOutOfBoundsException, IOException {
            if (index == s.length) {
                s = br.readLine().split(" ");
                index = 0;
            }
            return s[index++];
        }

        private void validate(int n, int start, int end) {
            if (start < 0 || end >= n) {
                throw new IllegalArgumentException();
            }
        }
    }

    static class Data implements Comparable<Data> {

        int a, b, c;

        public Data(int a, int b, int c) {
            this.a = a;
            this.b = b;
            this.c = c;
        }

        @Override
        public int compareTo(Data o) {
            if (a == o.a) {
                return Integer.compare(b, o.b);
            }
            return Integer.compare(a, o.a);
        }

//        public static void sort(int a[]) {
//            Data d[] = new Data[a.length];
//            for (int i = 0; i < a.length; i++) {
//                d[i] = new Data(a[i], 0);
//            }
//            Arrays.sort(d);
//            for (int i = 0; i < a.length; i++) {
//                a[i] = d[i].a;
//            }
//        }
    }
}
