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.
/**
 * Created by Aminul on 11/12/2018.
 */

import java.io.*;
import java.util.*;
import static java.lang.Math.*;

public class E {
    public static void main(String[] args) throws Exception {
        new Thread(null ,new Runnable(){
            public void run(){try{solveIt();} catch(Exception e){e.printStackTrace();
                e.printStackTrace(System.out);
            }}
        },"Main",1<<28).start();
    }

    public static void solveIt() throws Exception {
        FastReader in = new FastReader(System.in);
        PrintWriter pw = new PrintWriter(System.out);

        n = in.nextInt();
        treap = new MyTreap_With_Range_Update[n+1];
        treap[0] = new MyTreap_With_Range_Update();

        int from[] = new int[n-1], to[] = new int[n-1];
        for (int i = 0; i < n-1; i++) {
            int u = in.nextInt(), v = in.nextInt();
            from[i] = u;
            to[i] = v;
        }
        g = packU(n+1, from, to);
        level = new int[n+1];

        int q = in.nextInt();
        queries = genList(n+1);
        for (int i = 0; i < q; i++) {
            int u = in.nextInt(), d = in.nextInt(), v = in.nextInt();
            queries[u].add(new Query(u, d, v));
        }

        solve(1, 0);

        Node[] nodes = treap[1].toArray();
        long ans[] = new long[n+1];
        for(Node node : nodes) {
            ans[node.id] = node.val;
        }

        for (int i = 1; i <= n; i++) {
            pw.print(ans[i]+" ");
        }

        pw.println();

        pw.close();
    }

    static <T>List<T>[] genList(int n){
        List<T> list[] = new List[n];
        for(int i = 0; i < n; i++) list[i] = new ArrayList<T>();
        return list;
    }

    static int[][] packU(int n, int[] from, int[] to) {
        int[][] g = new int[n][];
        int[] p = new int[n];
        for (int f : from)
            p[f]++;
        for (int t : to)
            p[t]++;
        for (int i = 0; i < n; i++)
            g[i] = new int[p[i]];
        for (int i = 0; i < from.length; i++) {
            g[from[i]][--p[from[i]]] = to[i];
            g[to[i]][--p[to[i]]] = from[i];
        }
        return g;
    }

    static class Query {
        int u, d, v;
        Query(int U, int D, int V) {
            u = U; d = D; v =  V;
        }
        @Override
        public String toString() {
            return u+ " "+ d +" "+v;
        }
    }

    static MyTreap_With_Range_Update treap[];
    static int g[][];
    static List<Query> queries[];
    static int n;
    static int level[];

    static void solve(int u, int p) {
        level[u] = level[p] + 1;
        int maxTreap = 0;
        for(int v : g[u]) {
            if(v != p) {
                solve(v, u);
                if(treap[v].size() > treap[maxTreap].size()) {
                    maxTreap = v;
                }
            }
        }
        if(maxTreap != 0) {
            treap[u] = treap[maxTreap];
        }
        else treap[u] = new MyTreap_With_Range_Update();
        treap[u].insert(level[u], u);
        for(int v : g[u]) {
            if(v != p && v != maxTreap) {
                Node [] nodes = treap[v].toArray();
                for(Node node : nodes){
                    //node.priority = random();
                    node.left = null; node.right = null;
                    node.size = 1;
                    treap[u].insert(node);
                }
            }
        }

        for(Query q : queries[u]) {
            treap[u].applyQuery(q.d + level[u], q.v);
        }
    }

    static class Node {
        int key;
        int id;
        long sum, val, lazy;
        double priority;
        Node left,right;
        int size;
        Node(int key, int i) {
            id = i;
            this.key = key;
            this.sum = val = 0; // VERY VERY IMPORTANT !!!!
            priority = Math.random();
            size = 1;
        }

        void update() {
            size = 1 + getSize(left) + getSize(right);
            sum =  getSum(left) + getSum(right) + val;
        }
        int getSize(Node root) {
            return root == null ? 0 : root.size;
        }
        long getSum(Node root) {return root == null ? 0 : root.sum;}
    }

    static class MyTreap_With_Range_Update { // Add X to a range of nodes/values
        Node root;
        void insert(int k, int id){
            root = insert(root, k, id);
        }

        void insert(Node node) {
            root = insert(root, node);
        }

        void remove(int k){
            root = remove(root, k);
        }
        int getKth(int k){
            return kth(root, k);
        }
        int getSize(Node root) {
            return root == null ? 0 : root.size;
        }
        int size(){
            return getSize(root);
        }
        long getSum(Node root) {return root == null ? 0 : root.sum;}

        int orderOf(int k){ // number of elements < k
            return orderOf(root, k);
        }

        int orderOf(Node temp, int k){ // number of elements < k
            int x = 0;
            if(temp == null) return 0;
            if(temp.key < k) return getSize(temp.left) + 1 + orderOf(temp.right, k);
            else return orderOf(temp.left, k);
        }

        Node splitL, splitR;

        void splitRecursive(Node t, long x){
            if(t == null){
                splitL = null;
                splitR = null;
                return;
            }
            pushDown(t);
            if(t.key <= x){
                splitRecursive(t.right, x);
                t.right = splitL;
                splitL = t;
            }
            else{
                splitRecursive(t.left, x);
                t.left = splitR;
                splitR = t;
            }
            t.update();
        }

        void applyQuery(long d, long v) {
            splitRecursive(root, d);
            lazy_update(splitL, v);
            root = merge(splitL, splitR);
        }

        void lazy_update(Node root, long x){
            if(root != null){
                root.val += x;
                root.lazy += x;
                root.sum += (long)root.size * x;
            }
        }

        void pushDown(Node root){
            if(root == null || root.lazy == 0) return;
            if(root.left != null){
                root.left.val += root.lazy;
                root.left.lazy += root.lazy;
                root.left.sum += root.lazy * root.left.size;

            }
            if(root.right != null){
                root.right.val += root.lazy;
                root.right.lazy += root.lazy;
                root.right.sum += root.lazy * root.right.size;
            }
            root.lazy = 0;
        }


        Node merge(Node left, Node right) {
            pushDown(left); pushDown(right);
            if (left == null)
                return right;

            if (right == null)
                return left;
            if (left.priority > right.priority) {
                left.right = merge(left.right, right);
                left.update();
                return left;
            } else {
                right.left = merge(left, right.left);
                right.update();
                return right;
            }
        }

        Node insert(Node root, Node x) {
            splitRecursive(root, x.key);
            return merge(merge(splitL, x), splitR);
        }

        Node insert(Node root, int x, int id) {
            splitRecursive(root, x);
            return merge(merge(splitL, new Node(x, id)), splitR);
        }

        Node remove(Node root, int x) {
            if (root == null) {
                return null;
            }
            if (x < root.key) {
                root.left = remove(root.left, x);
                root.update();
                return root;
            } else if (x > root.key) {
                root.right = remove(root.right, x);
                root.update();
                return root;
            } else {
                return merge(root.left, root.right);
            }
        }

        int kth(Node n, int k) {
            if (n == null) return -1;
            int key = getSize(n.left) + 1;
            if (key > k) return kth(n.left, k);
            else if (key < k) return kth(n.right, k - key);
            return n.key;
        }

        void print(){
            print(root);
            System.out.println();
        }
        void print(Node root) {
            pushDown(root);
            if (root == null)
                return;
            print(root.left);
            System.out.print(root.id+","+root.sum+"; " );
            print(root.right);
        }

        Node arr[];
        int idx = 0;
        Node[] toArray(){
            arr = new Node[size()];
            idx = 0;
            toArray(root);
            return arr;
        }
        void toArray(Node root) {
            pushDown(root);
            if (root == null)
                return;
            toArray(root.left);
            arr[idx++] = root;
            //System.out.print(root.key+","+root.sum+"; " );
            toArray(root.right);
        }

    }

    static void debug(Object...obj) {
        System.out.println(Arrays.deepToString(obj));
    }

    static class FastReader {
        InputStream is;
        private byte[] inbuf = new byte[1024];
        private int lenbuf = 0, ptrbuf = 0;

        public FastReader(InputStream is) {
            this.is = is;
        }

        public int readByte() {
            if (lenbuf == -1) throw new InputMismatchException();
            if (ptrbuf >= lenbuf) {
                ptrbuf = 0;
                try {
                    lenbuf = is.read(inbuf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (lenbuf <= 0) return -1;
            }
            return inbuf[ptrbuf++];
        }

        public boolean isSpaceChar(int c) {
            return !(c >= 33 && c <= 126);
        }
        private boolean isEndOfLine(int c) {
            return c == '\n' || c == '\r' || c == -1;
        }

        public int skip() {
            int b;
            while ((b = readByte()) != -1 && isSpaceChar(b)) ;
            return b;
        }

        public String next() {
            int b = skip();
            StringBuilder sb = new StringBuilder();
            while (!(isSpaceChar(b))) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }



        public String nextLine() {
            int c = skip();
            StringBuilder sb = new StringBuilder();
            while (!isEndOfLine(c)){
                sb.appendCodePoint(c);
                c = readByte();
            }
            return sb.toString();
        }

        public int nextInt() {
            int num = 0, b;
            boolean minus = false;
            while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            while (true) {
                if (b >= '0' && b <= '9') {
                    num = (num << 3) + (num << 1) + (b - '0');
                } else {
                    return minus ? -num : num;
                }
                b = readByte();
            }
        }

        public long nextLong() {
            long num = 0;
            int b;
            boolean minus = false;
            while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
            if (b == '-') {
                minus = true;
                b = readByte();
            }

            while (true) {
                if (b >= '0' && b <= '9') {
                    num = (num << 3) + (num << 1) + (b - '0');
                } else {
                    return minus ? -num : num;
                }
                b = readByte();
            }
        }

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

        public char[] next(int n) {
            char[] buf = new char[n];
            int b = skip(), p = 0;
            while (p < n && !(isSpaceChar(b))) {
                buf[p++] = (char) b;
                b = readByte();
            }
            return n == p ? buf : Arrays.copyOf(buf, p);
        }

        public char readChar() {
            return (char) skip();
        }
    }
}