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.
/*
bts songs to dance to:
I need U
Run
ON
Filter
I'm fine
 */
import static java.lang.Math.max;
import static java.lang.Math.min;
import static java.lang.Math.abs;
import static java.lang.System.out;
import java.util.*;
import java.io.*;
import java.math.*;

public class x1076E
{
    static int[][] edges;
    public static void main(String hi[]) throws Exception
    {
        FastScanner infile = new FastScanner();
        N = infile.nextInt();
        ArrayDeque<Integer> input = new ArrayDeque<Integer>();
        int[] freq = new int[N+1];
        for(int i=1; i < N; i++)
        {
            int a = infile.nextInt();
            int b = infile.nextInt();
            freq[a]++;  freq[b]++;
            input.add(a);   input.add(b);
        }
        edges = new int[N+1][];
        for(int v=1; v <= N; v++)
            edges[v] = new int[freq[v]];
        while(input.size() > 0)
        {
            int a = input.poll();
            int b = input.poll();
            edges[a][--freq[a]] = b;
            edges[b][--freq[b]] = a;
        }
        buckets = new ArrayDeque[N+1];
        int M = infile.nextInt();
        for(int v=1; v <= M; v++)
        {
            int root = infile.nextInt();
            int d = infile.nextInt();
            int val = infile.nextInt();
            if(buckets[root] == null)
                buckets[root] = new ArrayDeque<Query>();
            buckets[root].add(new Query(d, val));
        }
        bit = new FenwickTree(N+2);
        res = new long[N+1];
        dfs(1, -1, 1);
        StringBuilder sb = new StringBuilder();
        for(int v=1; v <= N; v++)
            sb.append(res[v]+" ");
        System.out.println(sb);
    }
    static int N;
    static FenwickTree bit;
    static long[] res;
    static ArrayDeque<Query>[] buckets;
    public static void dfs(int curr, int par, int depth)
    {
        //create changes
        if(buckets[curr] != null)
            for(Query q: buckets[curr])
                bit.update(depth, min(depth+q.d, N), q.val);
        //dfs
        res[curr] = bit.query(depth, depth);
        for(int next: edges[curr])
            if(next != par)
                dfs(next, curr, depth+1);
        //rollback
        if(buckets[curr] != null)
            for(Query q: buckets[curr])
                bit.update(depth, min(depth+q.d, N), -q.val);
    }
}
class Query
{
    public int d;
    public int val;

    public Query(int a, int b)
    {
        d = a;
        val = b;
    }
}
class FenwickTree
{
    final long[] value;
    final long[] weightedVal;

    public FenwickTree(int treeTo)
    {
        value = new long[treeTo+2];
        weightedVal = new long[treeTo+2];
    }
    private void updateHelper(int index, long delta)
    {
        long weightedDelta = index*delta;
        for(int j = index; j < value.length; j += j & -j)
        {
            value[j] += delta;
            weightedVal[j] += weightedDelta;
        }
    }
    public void update(int from, int to, long delta)
    {
        updateHelper(from, delta);
        updateHelper(to + 1, -delta);
    }
    private long query(int to)
    {
        long res = 0;
        long weightedRes = 0;
        for (int j = to; j > 0; j -= j & -j)
        {
            res += value[j];
            weightedRes += weightedVal[j];
        }
        return ((to + 1)*res)-weightedRes;
    }
    public long query(int from, int to)
    {
        if (to < from)
            return 0;
        return query(to) - query(from - 1);
    }
}
class FastScanner
{
    private int BS = 1 << 16;
    private char NC = (char) 0;
    private byte[] buf = new byte[BS];
    private int bId = 0, size = 0;
    private char c = NC;
    private double cnt = 1;
    private BufferedInputStream in;

    public FastScanner() {
        in = new BufferedInputStream(System.in, BS);
    }

    public FastScanner(String s) {
        try {
            in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
        } catch (Exception e) {
            in = new BufferedInputStream(System.in, BS);
        }
    }

    private char getChar() {
        while (bId == size) {
            try {
                size = in.read(buf);
            } catch (Exception e) {
                return NC;
            }
            if (size == -1) return NC;
            bId = 0;
        }
        return (char) buf[bId++];
    }

    public int nextInt() {
        return (int) nextLong();
    }

    public int[] nextInts(int N) {
        int[] res = new int[N];
        for (int i = 0; i < N; i++) {
            res[i] = (int) nextLong();
        }
        return res;
    }

    public long[] nextLongs(int N) {
        long[] res = new long[N];
        for (int i = 0; i < N; i++) {
            res[i] = nextLong();
        }
        return res;
    }

    public long nextLong() {
        cnt = 1;
        boolean neg = false;
        if (c == NC) c = getChar();
        for (; (c < '0' || c > '9'); c = getChar()) {
            if (c == '-') neg = true;
        }
        long res = 0;
        for (; c >= '0' && c <= '9'; c = getChar()) {
            res = (res << 3) + (res << 1) + c - '0';
            cnt *= 10;
        }
        return neg ? -res : res;
    }

    public double nextDouble() {
        double cur = nextLong();
        return c != '.' ? cur : cur + nextLong() / cnt;
    }

    public double[] nextDoubles(int N) {
        double[] res = new double[N];
        for (int i = 0; i < N; i++) {
            res[i] = nextDouble();
        }
        return res;
    }

    public String next() {
        StringBuilder res = new StringBuilder();
        while (c <= 32) c = getChar();
        while (c > 32) {
            res.append(c);
            c = getChar();
        }
        return res.toString();
    }

    public String nextLine() {
        StringBuilder res = new StringBuilder();
        while (c <= 32) c = getChar();
        while (c != '\n') {
            res.append(c);
            c = getChar();
        }
        return res.toString();
    }

    public boolean hasNext() {
        if (c > 32) return true;
        while (true) {
            c = getChar();
            if (c == NC) return false;
            else if (c > 32) return true;
        }
    }
}