import std.algorithm;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.meta;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;

auto solve(uint N, uint Q, uint[] a, uint[] b, uint[] p, uint[] x){
    auto edges = new uint[][](N + 1, 0);
    foreach (ai, bi; zip(a, b)) {
        edges[ai] ~= bi;
        edges[bi] ~= ai;
    }

    auto nodes = new uint[](N + 1);
    foreach (pi, xi; zip(p, x)) {
        nodes[pi] += xi;
    }

    auto visited = new bool[](N + 1);
    dig(nodes, edges, 1, 0, visited);

    return nodes[1 .. $].map!(to!string).join(" ");
}

void dig(uint[] nodes, uint[][] edges, uint nodei, uint acc, bool[] visited) {
    visited[nodei] = true;
    acc = (nodes[nodei] += acc);
    foreach (childi; edges[nodei]) {
        if (visited[childi])
            continue;
        dig(nodes, edges, childi, acc, visited);
    }
}

void main(){
    auto input = stdin.byLine.map!split.joiner;

    uint N;
    N = input.front.to!uint;
    input.popFront;

    uint Q;
    Q = input.front.to!uint;
    input.popFront;

    uint[] a = new uint[](cast(size_t) (N-1));
    uint[] b = new uint[](cast(size_t) (N-1));
    foreach (i; 0 .. cast(size_t) (N-1)) {
        a[i] = input.front.to!uint;
        input.popFront;
        b[i] = input.front.to!uint;
        input.popFront;
    }

    uint[] p = new uint[](cast(size_t) (Q));
    uint[] x = new uint[](cast(size_t) (Q));
    foreach (i; 0 .. cast(size_t) (Q)) {
        p[i] = input.front.to!uint;
        input.popFront;
        x[i] = input.front.to!uint;
        input.popFront;
    }

    static if (is(ReturnType!solve == void))
        solve(N, Q, a, b, p, x);
    else
        solve(N, Q, a, b, p, x).writeln;
}
