import sys

sys.setrecursionlimit(10**7)



def input():

    return sys.stdin.readline()[:-1]



n, q = list(map(int,input().split()))

g = [[] for _ in range(n+1)]

for  _ in range(n-1):

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

    g[a].append(b)

    g[b].append(a)

points = [0]*(n+1)

for _ in range(q):

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

    points[p] += x

# print(g)

# print(points)

def dfs(e,preve = -1):

    for nexte in g[e]:

        # print(nexte)

        if nexte == preve:

            continue

        points[nexte] = points[nexte] + points[e]

        dfs(nexte,e)

dfs(1)

print((*points[1:]))



import sys

sys.setrecursionlimit(10**7)



def input():

    return sys.stdin.readline()



n, q = list(map(int,input().split()))

g = [[] for _ in range(n+1)]

for  _ in range(n-1):

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

    g[a].append(b)

    g[b].append(a)

points = [0]*(n+1)

for _ in range(q):

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

    points[p] += x

# print(g)

# print(points)

def dfs(e,preve = -1):

    for nexte in g[e]:

        # print(nexte)

        if nexte == preve:

            continue

        points[nexte] = points[nexte] + points[e]

        dfs(nexte,e)

dfs(1)

print((*points[1:]))



import sys

sys.setrecursionlimit(10**7)


def input():
    return sys.stdin.readline()[:-1]


n, q = list(map(int, input().split()))
g = [[] for _ in range(n + 1)]
for _ in range(n - 1):
    a, b = list(map(int, input().split()))
    g[a].append(b)
    g[b].append(a)
points = [0] * (n + 1)
for _ in range(q):
    p, x = list(map(int, input().split()))
    points[p] += x
# print(g)
# print(points)
def dfs(e, preve=-1):
    for nexte in g[e]:
        # print(nexte)
        if nexte == preve:
            continue
        points[nexte] = points[nexte] + points[e]
        dfs(nexte, e)


dfs(1)
print((*points[1:]))

import sys

sys.setrecursionlimit(10**7)


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


n, q = list(map(int, input().split()))
g = [[] for _ in range(n + 1)]
for _ in range(n - 1):
    a, b = list(map(int, input().split()))
    g[a].append(b)
    g[b].append(a)
points = [0] * (n + 1)
for _ in range(q):
    p, x = list(map(int, input().split()))
    points[p] += x
# print(g)
# print(points)
def dfs(e, preve=-1):
    for nexte in g[e]:
        # print(nexte)
        if nexte == preve:
            continue
        points[nexte] = points[nexte] + points[e]
        dfs(nexte, e)


dfs(1)
print((*points[1:]))

-    return sys.stdin.readline()[:-1] +    return sys.stdin.readline()