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



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

for _ in range(n - 1):

    a, b = (int(x) - 1 for x in input().split())

    g[a].add(b)

    g[b].add(a)



ctr = [0] * n

for _ in range(q):

    it = list(map(int, input().split()))

    p = next(it) - 1

    x = next(it)

    ctr[p] += x



st = [0]

used = [0] * n

used[0] = 1

while st:

    v = st.pop()

    for u in g[v]:

        if used[u]: continue

        used[u] = 1

        ctr[u] += ctr[v]

        st.append(u)

print((*ctr))

def main():

    import sys

    input = sys.stdin.readline



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



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

    for _ in range(n - 1):

        a, b = (int(x) - 1 for x in input().split())

        g[a].add(b)

        g[b].add(a)



    ctr = [0] * n

    for _ in range(q):

        it = list(map(int, input().split()))

        p = next(it) - 1

        x = next(it)

        ctr[p] += x



    st = [0]

    used = [0] * n

    used[0] = 1

    while st:

        v = st.pop()

        for u in g[v]:

            if used[u]: continue

            used[u] = 1

            ctr[u] += ctr[v]

            st.append(u)

    print((*ctr))





if __name__ == '__main__':

    main()

n, q = list(map(int, input().split()))
g = [set() for _ in range(n)]
for _ in range(n - 1):
    a, b = (int(x) - 1 for x in input().split())
    g[a].add(b)
    g[b].add(a)
ctr = [0] * n
for _ in range(q):
    it = list(map(int, input().split()))
    p = next(it) - 1
    x = next(it)
    ctr[p] += x
st = [0]
used = [0] * n
used[0] = 1
while st:
    v = st.pop()
    for u in g[v]:
        if used[u]:
            continue
        used[u] = 1
        ctr[u] += ctr[v]
        st.append(u)
print((*ctr))

def main():
    import sys

    input = sys.stdin.readline
    n, q = list(map(int, input().split()))
    g = [set() for _ in range(n)]
    for _ in range(n - 1):
        a, b = (int(x) - 1 for x in input().split())
        g[a].add(b)
        g[b].add(a)
    ctr = [0] * n
    for _ in range(q):
        it = list(map(int, input().split()))
        p = next(it) - 1
        x = next(it)
        ctr[p] += x
    st = [0]
    used = [0] * n
    used[0] = 1
    while st:
        v = st.pop()
        for u in g[v]:
            if used[u]:
                continue
            used[u] = 1
            ctr[u] += ctr[v]
            st.append(u)
    print((*ctr))


if __name__ == "__main__":
    main()

-n, q = list(map(int, input().split())) -g = [set() for _ in range(n)] -for _ in range(n - 1): -    a, b = (int(x) - 1 for x in input().split()) -    g[a].add(b) -    g[b].add(a) -ctr = [0] * n -for _ in range(q): -    it = list(map(int, input().split())) -    p = next(it) - 1 -    x = next(it) -    ctr[p] += x -st = [0] -used = [0] * n -used[0] = 1 -while st: -    v = st.pop() -    for u in g[v]: -        if used[u]: -            continue -        used[u] = 1 -        ctr[u] += ctr[v] -        st.append(u) -print((*ctr)) +def main(): +    import sys + +    input = sys.stdin.readline +    n, q = list(map(int, input().split())) +    g = [set() for _ in range(n)] +    for _ in range(n - 1): +        a, b = (int(x) - 1 for x in input().split()) +        g[a].add(b) +        g[b].add(a) +    ctr = [0] * n +    for _ in range(q): +        it = list(map(int, input().split())) +        p = next(it) - 1 +        x = next(it) +        ctr[p] += x +    st = [0] +    used = [0] * n +    used[0] = 1 +    while st: +        v = st.pop() +        for u in g[v]: +            if used[u]: +                continue +            used[u] = 1 +            ctr[u] += ctr[v] +            st.append(u) +    print((*ctr)) + + +if __name__ == "__main__": +    main()