def main():

    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()
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()
def main():
    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()

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