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


public class Main {
    static final long INF = (long) 1e15;
    static final int UNCALC = -1;
    static ArrayList<Integer> adjList[];
    static ArrayList<Pair> q[];
    static long ans[];
    static SegmentTree st;

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int n = sc.nextInt();
        int m = n - 1;
        adjList = new ArrayList[n];
        q = new ArrayList[n];
        ans = new long[n];
        for (int i = 0; i < n; i++) {
            adjList[i] = new ArrayList<>();
            q[i] = new ArrayList<>();
        }
        while (m-- > 0) {
            int u = sc.nextInt() - 1;
            int v = sc.nextInt() - 1;
            adjList[u].add(v);
            adjList[v].add(u);
        }
        m = sc.nextInt();
        while (m-- > 0) {
            int u = sc.nextInt() - 1;
            int d = sc.nextInt();
            int x = sc.nextInt();
            q[u].add(new Pair(d, x));
        }
        st = new SegmentTree(n);
        dfs(0, 0, 1);
        for (long x : ans)
            out.print(x + " ");
        out.flush();
        out.close();
    }

    static void dfs(int u, int p, int level) {
        for (Pair query : q[u])
            st.update_range(level, level + query.d, query.x);
        ans[u] += st.query(level);
        for (int v : adjList[u])
            if (v != p) dfs(v, u, level + 1);
        for (Pair query : q[u])
            st.update_range(level, level + query.d, -query.x);
    }

    static class Pair {
        int d, x;

        public Pair(int d, int x) {
            this.d = d;
            this.x = x;
        }

    }

    static class SegmentTree {
        int N;
        long[] sTree, lazy;

        public SegmentTree(int n) {
            N = 1;
            while (N < n)
                N <<= 1;
            sTree = new long[N << 1];
            lazy = new long[N << 1];
        }

        void update_range(int i, int j, int val) {
            update_range(1, 1, N, i, j, val);
        }

        void update_range(int node, int b, int e, int i, int j, int val) {
            if (b > j || e < i)
                return;
            if (b >= i && e <= j) {
                sTree[node] += val;
                lazy[node] += val;
                return;
            }
            int mid = (b + e) >> 1;
            update_range(node << 1, b, mid, i, j, val);
            update_range(node << 1 | 1, mid + 1, e, i, j, val);
            sTree[node] = sTree[node << 1] + sTree[node << 1 | 1];
        }

        long query(int node, int b, int e, int i, int j) {
            if (b > j || e < i)
                return 0;
            if (b >= i && e <= j)
                return sTree[node];
            int mid = (b + e) >> 1;
            propagate(node, b, mid, e);
            long q1 = query(node << 1, b, mid, i, j);
            long q2 = query(node << 1 | 1, mid + 1, e, i, j);
            return q1 + q2;
        }

        long query(int p) {
            return query(1, 1, N, p, p);
        }

        void propagate(int node, int b, int mid, int e) {
            lazy[node << 1] += lazy[node];
            lazy[node << 1 | 1] += lazy[node];
            sTree[node << 1] += (mid - b + 1) * lazy[node];
            sTree[node << 1 | 1] += (e - mid) * lazy[node];
            lazy[node] = 0;
        }
    }


    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream system) {
            br = new BufferedReader(new InputStreamReader(system));
        }

        public Scanner(String file) throws Exception {
            br = new BufferedReader(new FileReader(file));
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

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

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

        public char nextChar() throws IOException {
            return next().charAt(0);
        }

        public Long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public boolean ready() throws IOException {
            return br.ready();
        }

        public void waitForInput() throws InterruptedException {
            Thread.sleep(3000);
        }

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

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

        public double[] nextDoubleArray(int n) throws IOException {
            double[] ans = new double[n];
            for (int i = 0; i < n; i++)
                ans[i] = nextDouble();
            return ans;
        }

    }
}
