def main():

    import sys

    sys.setrecursionlimit(300000)

    n, q, *abpx = list(map(int, sys.stdin.read().split()))



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

    for u, v in zip(*[iter(abpx[:2 * (n - 1)])] * 2):

        g[u].append(v)

        g[v].append(u)



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



    for p, x in zip(*[iter(abpx[2 * (n - 1):])] * 2):

        f[p] += x



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

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



    def c(i, p):

        if vis[i]:

            return

        vis[i] = True

        w = f[i] + p

        k[i] = w

        ch = g[i]

        for x in ch:

            c(x, w)

    c(1, 0)

    ans = ' '.join(map(str, k[1:]))

    print(ans)





if __name__ == '__main__':

    main()

def main():

    from collections import deque



    n, q, *abpx = list(map(int, open(0).read().split()))



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

    for u, v in zip(*[iter(abpx[:2 * (n - 1)])] * 2):

        g[u].append(v)

        g[v].append(u)



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



    for p, x in zip(*[iter(abpx[2 * (n - 1):])] * 2):

        f[p] += x



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

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



    q = deque([])

    q.append([1, 0])

    while q:

        i, c = q.pop()

        if vis[i]:

            continue

        vis[i] = True

        ch = g[i]

        w = c + f[i]

        k[i] = w

        for u, v in zip(ch, [w] * len(ch)):

            q.appendleft([u, v])



    ans = ' '.join(map(str, k[1:]))

    print(ans)





if __name__ == '__main__':

    main()

def main():
    import sys

    sys.setrecursionlimit(300000)
    n, q, *abpx = list(map(int, sys.stdin.read().split()))
    g = [[] for _ in range(n + 1)]
    for u, v in zip(*[iter(abpx[: 2 * (n - 1)])] * 2):
        g[u].append(v)
        g[v].append(u)
    f = [0 for _ in range(n + 1)]
    for p, x in zip(*[iter(abpx[2 * (n - 1) :])] * 2):
        f[p] += x
    k = [0 for _ in range(n + 1)]
    vis = [False for _ in range(n + 1)]

    def c(i, p):
        if vis[i]:
            return
        vis[i] = True
        w = f[i] + p
        k[i] = w
        ch = g[i]
        for x in ch:
            c(x, w)

    c(1, 0)
    ans = " ".join(map(str, k[1:]))
    print(ans)


if __name__ == "__main__":
    main()

def main():
    from collections import deque

    n, q, *abpx = list(map(int, open(0).read().split()))
    g = [[] for _ in range(n + 1)]
    for u, v in zip(*[iter(abpx[: 2 * (n - 1)])] * 2):
        g[u].append(v)
        g[v].append(u)
    f = [0 for _ in range(n + 1)]
    for p, x in zip(*[iter(abpx[2 * (n - 1) :])] * 2):
        f[p] += x
    k = [0 for _ in range(n + 1)]
    vis = [False for _ in range(n + 1)]
    q = deque([])
    q.append([1, 0])
    while q:
        i, c = q.pop()
        if vis[i]:
            continue
        vis[i] = True
        ch = g[i]
        w = c + f[i]
        k[i] = w
        for u, v in zip(ch, [w] * len(ch)):
            q.appendleft([u, v])
    ans = " ".join(map(str, k[1:]))
    print(ans)


if __name__ == "__main__":
    main()

-    import sys +    from collections import deque -    sys.setrecursionlimit(300000) -    n, q, *abpx = list(map(int, sys.stdin.read().split())) +    n, q, *abpx = list(map(int, open(0).read().split())) - -    def c(i, p): +    q = deque([]) +    q.append([1, 0]) +    while q: +        i, c = q.pop() -            return +            continue -        w = f[i] + p +        ch = g[i] +        w = c + f[i] -        ch = g[i] -        for x in ch: -            c(x, w) - -    c(1, 0) +        for u, v in zip(ch, [w] * len(ch)): +            q.appendleft([u, v])