def main():

    import sys

    input = sys.stdin.readline

    sys.setrecursionlimit(10000000)



    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 _ 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()



def main():

  import sys

  sys.setrecursionlimit(500000)

  input = sys.stdin.readline



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

  G = [[] 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].append(b)

      G[b].append(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()

def main():
    import sys

    input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    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 _ 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()

def main():
    import sys

    sys.setrecursionlimit(500000)
    input = sys.stdin.readline
    N, Q = list(map(int, input().split()))
    G = [[] 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].append(b)
        G[b].append(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()

+    sys.setrecursionlimit(500000) -    sys.setrecursionlimit(10000000) -    G = [set() for _ in range(N)] +    G = [[] for _ in range(N)] -        G[a].add(b) -        G[b].add(a) -    for _ in range(Q): +        G[a].append(b) +        G[b].append(a) +    for i in range(Q):