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.*;
import java.util.*;

public class Main {

    public static final int N = 300100;

    public static int n, m;
    public static Node[] g;
    public static long[] ans;
    public static long[] BIT = new long[N];

    public static void solve(FastIO io) {
        n = io.nextInt();

        g = new Node[n];
        ans = new long[n];

        for(int i = 0; i < n; ++i)
            g[i] = new Node();

        for(int i = 0, u, v; i < n-1; ++i){
            u = io.nextInt()-1; v = io.nextInt()-1;
            g[u].nxt.add(v);
            g[v].nxt.add(u);
        }

        m = io.nextInt();
        for(int i = 0, u, x, d; i < m; ++i){
            u = io.nextInt()-1;
            d = io.nextInt();
            x = io.nextInt();
            g[u].q.add(new Pair<>(x, d));
        }

        dfs(0, -1, 1);

        io.printArray(ans);
    }

    public static void dfs(int u, int p, int h){

        for(Pair<Integer, Integer> qu : g[u].q){
            int l = h, r = h + qu.d;
            updRng(l, r, qu.x);
        }

        ans[u] = get(h);
        for(int v : g[u].nxt){
            if(v == p) continue;
            dfs(v, u, h+1);
        }

        for(Pair<Integer, Integer> qu : g[u].q){
            int l = h, r = h + qu.d;
            updRng(l, r, -qu.x);
        }
    }

    public static void upd(int idx, int x){
        while(idx < N){
            BIT[idx] += x;
            idx += idx & -idx;
        }
    }

    public static void updRng(int l, int r, int x){
        upd(l, x); upd(r+1, -x);
    }

    public static long get(int idx){
        long res = 0;
        while(idx > 0){
            res += BIT[idx];
            idx -= idx & -idx;
        }

        return res;
    }

    public static class Pair<T1, T2> {
        T1 x; T2 d;

        Pair(T1 first, T2 second){
            this.x = first;
            this.d = second;
        }
    }

    public static class Node {
        ArrayList<Integer> nxt;
        ArrayList<Pair<Integer, Integer>> q;

        Node(){
            nxt = new ArrayList<>();
            q = new ArrayList<>();
        }
    }

    public static class FastIO {
        private InputStream reader;
        private PrintWriter writer;

        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public FastIO(InputStream r, OutputStream w) {
            reader = r;
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(w)));
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = reader.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public String nextLine() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isEndOfLine(c));
            return res.toString();
        }

        public String nextString() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public long nextLong() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long 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 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 int[] nextIntArray(int n) {
            return nextIntArray(n, 0);
        }

        public int[] nextIntArray(int n, int off) {
            int[] arr = new int[n + off];
            for (int i = 0; i < n; i++) {
                arr[i + off] = nextInt();
            }
            return arr;
        }

        public long[] nextLongArray(int n) {
            return nextLongArray(n, 0);
        }

        public long[] nextLongArray(int n, int off) {
            long[] arr = new long[n + off];
            for (int i = 0; i < n; i++) {
                arr[i + off] = nextLong();
            }
            return arr;
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        private boolean isEndOfLine(int c) {
            return c == '\n' || c == '\r' || c == -1;
        }

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

        public void println(Object... objects) {
            print(objects);
            writer.println();
        }

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

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

        public void printlnArray(int[] arr) {
            printArray(arr);
            writer.println();
        }

        public void printlnArray(long[] arr) {
            printArray(arr);
            writer.println();
        }

        public void printf(String format, Object... args) {
            print(String.format(format, args));
        }

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

    public static void main(String[] args) throws FileNotFoundException {
        FastIO io = new FastIO(System.in, System.out);
        solve(io);
        io.flush();
    }
}