import sys

sys.setrecursionlimit(10 ** 6)





def dfs(v, pv):

    for nv in g[v]:

        if nv == pv:

            continue

        cnt[nv] += cnt[v]

        dfs(nv, v)





(N, Q), *ABPX = [list(map(int, s.split())) for s in open(0)]

g = [set() for _ in range(N)]

for a, b in ABPX[:N - 1]:

    g[a - 1].add(b - 1)

    g[b - 1].add(a - 1)



cnt = [0] * N

for p, x in ABPX[N - 1:]:

    cnt[p - 1] += x

dfs(0, -1)

print((*cnt))

import sys





sys.setrecursionlimit(10 ** 6)





def dfs(v):

    print(counter)

    for nv in g[v]:

        if nv in visited:

            continue

        visited.add(nv)

        counter[nv] += counter[v]

        dfs(nv)





def input():

    return sys.stdin.readline().strip()





N, Q = list(map(int, input().split()))

g = [set() for _ in range(N)]

for _ in range(N - 1):

    a, b = list(map(int, input().split()))

    a -= 1

    b -= 1

    g[a].add(b)

    g[b].add(a)

counter = [0] * N

for _ in range(Q):

    p, x = list(map(int, input().split()))

    p -= 1

    counter[p] += x



stack = [0]

visited = {0}

while stack:

    v = stack.pop()

    for nv in g[v]:

        if nv in visited:

            continue

        stack.append(nv)

        visited.add(nv)

        counter[nv] += counter[v]

print((" ".join(map(str, counter))))

import sys

sys.setrecursionlimit(10**6)


def dfs(v, pv):
    for nv in g[v]:
        if nv == pv:
            continue
        cnt[nv] += cnt[v]
        dfs(nv, v)


(N, Q), *ABPX = [list(map(int, s.split())) for s in open(0)]
g = [set() for _ in range(N)]
for a, b in ABPX[: N - 1]:
    g[a - 1].add(b - 1)
    g[b - 1].add(a - 1)
cnt = [0] * N
for p, x in ABPX[N - 1 :]:
    cnt[p - 1] += x
dfs(0, -1)
print((*cnt))

import sys

sys.setrecursionlimit(10**6)


def dfs(v):
    print(counter)
    for nv in g[v]:
        if nv in visited:
            continue
        visited.add(nv)
        counter[nv] += counter[v]
        dfs(nv)


def input():
    return sys.stdin.readline().strip()


N, Q = list(map(int, input().split()))
g = [set() for _ in range(N)]
for _ in range(N - 1):
    a, b = list(map(int, input().split()))
    a -= 1
    b -= 1
    g[a].add(b)
    g[b].add(a)
counter = [0] * N
for _ in range(Q):
    p, x = list(map(int, input().split()))
    p -= 1
    counter[p] += x
stack = [0]
visited = {0}
while stack:
    v = stack.pop()
    for nv in g[v]:
        if nv in visited:
            continue
        stack.append(nv)
        visited.add(nv)
        counter[nv] += counter[v]
print((" ".join(map(str, counter))))

-def dfs(v, pv): +def dfs(v): +    print(counter) -        if nv == pv: +        if nv in visited: -        cnt[nv] += cnt[v] -        dfs(nv, v) +        visited.add(nv) +        counter[nv] += counter[v] +        dfs(nv) -(N, Q), *ABPX = [list(map(int, s.split())) for s in open(0)] +def input(): +    return sys.stdin.readline().strip() + + +N, Q = list(map(int, input().split())) -for a, b in ABPX[: N - 1]: -    g[a - 1].add(b - 1) -    g[b - 1].add(a - 1) -cnt = [0] * N -for p, x in ABPX[N - 1 :]: -    cnt[p - 1] += x -dfs(0, -1) -print((*cnt)) +for _ in range(N - 1): +    a, b = list(map(int, input().split())) +    a -= 1 +    b -= 1 +    g[a].add(b) +    g[b].add(a) +counter = [0] * N +for _ in range(Q): +    p, x = list(map(int, input().split())) +    p -= 1 +    counter[p] += x +stack = [0] +visited = {0} +while stack: +    v = stack.pop() +    for nv in g[v]: +        if nv in visited: +            continue +        stack.append(nv) +        visited.add(nv) +        counter[nv] += counter[v] +print((" ".join(map(str, counter))))