def main():

    import sys

    input=sys.stdin.readline

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

    from collections import deque,defaultdict

    dic=defaultdict(list)

    for i in range(n-1):

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

        dic[x-1].append(y-1)

        dic[y-1].append(x-1)

    cnt=[0]*n

    for i in range(q):

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

        cnt[x-1]+=y

    

    d=deque()

    d.append(0)

    completed=[False]*n

    while d:

        now=d.popleft()

        completed[now]=True

        for x in dic[now]:

            if completed[x]==False:

                cnt[x]+=cnt[now]

                d.append(x)

    print((*cnt))



if __name__=="__main__":

    main()
import sys

input=sys.stdin.readline

def main():

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

    tree=[[]*n for i in range(n)]

    score=[0]*n

    

    for i in range(n-1):

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

        tree[x-1].append(y-1)

        tree[y-1].append(x-1)

        

    for i in range(q):

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

        score[x-1]+=y

    

    from collections import deque

    option=deque()

    option.append(0)

    completed=[None]*n

    

    while option:

        before=option.pop()

        completed[before]=True

        for i in tree[before]:

            if completed[i]==None:

                score[i]+=score[before]

                option.append(i)

    print((*score))

if __name__=="__main__":

    main()
def main():
    import sys

    input = sys.stdin.readline
    n, q = list(map(int, input().split()))
    from collections import deque, defaultdict

    dic = defaultdict(list)
    for i in range(n - 1):
        x, y = list(map(int, input().split()))
        dic[x - 1].append(y - 1)
        dic[y - 1].append(x - 1)
    cnt = [0] * n
    for i in range(q):
        x, y = list(map(int, input().split()))
        cnt[x - 1] += y
    d = deque()
    d.append(0)
    completed = [False] * n
    while d:
        now = d.popleft()
        completed[now] = True
        for x in dic[now]:
            if completed[x] == False:
                cnt[x] += cnt[now]
                d.append(x)
    print((*cnt))


if __name__ == "__main__":
    main()

import sys

input = sys.stdin.readline


def main():
    n, q = list(map(int, input().split()))
    tree = [[] * n for i in range(n)]
    score = [0] * n
    for i in range(n - 1):
        x, y = list(map(int, input().split()))
        tree[x - 1].append(y - 1)
        tree[y - 1].append(x - 1)
    for i in range(q):
        x, y = list(map(int, input().split()))
        score[x - 1] += y
    from collections import deque

    option = deque()
    option.append(0)
    completed = [None] * n
    while option:
        before = option.pop()
        completed[before] = True
        for i in tree[before]:
            if completed[i] == None:
                score[i] += score[before]
                option.append(i)
    print((*score))


if __name__ == "__main__":
    main()

+import sys + +input = sys.stdin.readline + + -    import sys - -    input = sys.stdin.readline -    from collections import deque, defaultdict - -    dic = defaultdict(list) +    tree = [[] * n for i in range(n)] +    score = [0] * n -        dic[x - 1].append(y - 1) -        dic[y - 1].append(x - 1) -    cnt = [0] * n +        tree[x - 1].append(y - 1) +        tree[y - 1].append(x - 1) -        cnt[x - 1] += y -    d = deque() -    d.append(0) -    completed = [False] * n -    while d: -        now = d.popleft() -        completed[now] = True -        for x in dic[now]: -            if completed[x] == False: -                cnt[x] += cnt[now] -                d.append(x) -    print((*cnt)) +        score[x - 1] += y +    from collections import deque + +    option = deque() +    option.append(0) +    completed = [None] * n +    while option: +        before = option.pop() +        completed[before] = True +        for i in tree[before]: +            if completed[i] == None: +                score[i] += score[before] +                option.append(i) +    print((*score))