import sys

sys.setrecursionlimit(500000)

input = sys.stdin.readline



N, Q = list(map(int, input().split()))

G = [set() for _ in range(N)]

cnt = [0]*N

visited = [0]*N



for _ in range(N-1):

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

    a -= 1

    b -= 1

    G[a].add(b)

    G[b].add(a)



for i in range(Q):

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

    p = next(it) - 1

    x = next(it)

    cnt[p] += x



visited[0]=1

st = [0]

while st:

    v = st.pop()

    for u in G[v]:

        if visited[u]:

            continue

        visited[u] = 1

        cnt[u] += cnt[v]

        st.append(u)    



print((*cnt))

def main():

  import sys

  sys.setrecursionlimit(500000)

  input = sys.stdin.readline



  N, Q = list(map(int, input().split()))

  G = [set() for _ in range(N)]

  cnt = [0]*N

  visited = [0]*N



  for _ in range(N-1):

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

      a -= 1

      b -= 1

      G[a].add(b)

      G[b].add(a)



  for i in range(Q):

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

      node -= 1

      cnt[node] += x



  visited[0]=1

  st = [0]

  while st:

      v = st.pop()

      for u in G[v]:

          if visited[u]:

              continue

          visited[u] = 1

          cnt[u] += cnt[v]

          st.append(u)    



  print((*cnt))

if __name__ == '__main__':

    main()
import sys

sys.setrecursionlimit(500000)
input = sys.stdin.readline
N, Q = list(map(int, input().split()))
G = [set() for _ in range(N)]
cnt = [0] * N
visited = [0] * N
for _ in range(N - 1):
    a, b = list(map(int, input().split()))
    a -= 1
    b -= 1
    G[a].add(b)
    G[b].add(a)
for i in range(Q):
    it = list(map(int, input().split()))
    p = next(it) - 1
    x = next(it)
    cnt[p] += x
visited[0] = 1
st = [0]
while st:
    v = st.pop()
    for u in G[v]:
        if visited[u]:
            continue
        visited[u] = 1
        cnt[u] += cnt[v]
        st.append(u)
print((*cnt))

def main():
    import sys

    sys.setrecursionlimit(500000)
    input = sys.stdin.readline
    N, Q = list(map(int, input().split()))
    G = [set() for _ in range(N)]
    cnt = [0] * N
    visited = [0] * N
    for _ in range(N - 1):
        a, b = list(map(int, input().split()))
        a -= 1
        b -= 1
        G[a].add(b)
        G[b].add(a)
    for i in range(Q):
        node, x = list(map(int, input().split()))
        node -= 1
        cnt[node] += x
    visited[0] = 1
    st = [0]
    while st:
        v = st.pop()
        for u in G[v]:
            if visited[u]:
                continue
            visited[u] = 1
            cnt[u] += cnt[v]
            st.append(u)
    print((*cnt))


if __name__ == "__main__":
    main()

-import sys +def main(): +    import sys -sys.setrecursionlimit(500000) -input = sys.stdin.readline -N, Q = list(map(int, input().split())) -G = [set() for _ in range(N)] -cnt = [0] * N -visited = [0] * N -for _ in range(N - 1): -    a, b = list(map(int, input().split())) -    a -= 1 -    b -= 1 -    G[a].add(b) -    G[b].add(a) -for i in range(Q): -    it = list(map(int, input().split())) -    p = next(it) - 1 -    x = next(it) -    cnt[p] += x -visited[0] = 1 -st = [0] -while st: -    v = st.pop() -    for u in G[v]: -        if visited[u]: -            continue -        visited[u] = 1 -        cnt[u] += cnt[v] -        st.append(u) -print((*cnt)) +    sys.setrecursionlimit(500000) +    input = sys.stdin.readline +    N, Q = list(map(int, input().split())) +    G = [set() for _ in range(N)] +    cnt = [0] * N +    visited = [0] * N +    for _ in range(N - 1): +        a, b = list(map(int, input().split())) +        a -= 1 +        b -= 1 +        G[a].add(b) +        G[b].add(a) +    for i in range(Q): +        node, x = list(map(int, input().split())) +        node -= 1 +        cnt[node] += x +    visited[0] = 1 +    st = [0] +    while st: +        v = st.pop() +        for u in G[v]: +            if visited[u]: +                continue +            visited[u] = 1 +            cnt[u] += cnt[v] +            st.append(u) +    print((*cnt)) + + +if __name__ == "__main__": +    main()