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

tree={}

for i in range(N-1):

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

  if (a-1) in tree:

    tree[a-1].append(b-1)

  else:

    tree[a-1]=[b-1]

  if (b-1) in tree:

    tree[b-1].append(a-1)

  else:

    tree[b-1]=[a-1]



point=[0]*N



for i in range(Q):

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

  point[p-1]+=x



ans=[0]*N

stack=[]

stack.append([0,0,-1])

while len(stack)>0:

  nodes=stack.pop()

  node=nodes[0]

  sump=nodes[1]

  parent=nodes[2]

  sump=sump+point[node]

  ans[node]=sump

  if node in tree:

      childs=tree[node]

      for child in childs:

        if child!=parent:

          stack.append([child,sump,node])



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

E=[[] for i in range(N)]

for i in range(N-1):

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

  a,b=a-1,b-1

  E[a].append(b)

  E[b].append(a)

  

P=[0]*N

for i in range(Q):

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

  P[p-1]+=x

  

ans=[0]*N

stack=[]

# 点,親,ポイント

stack.append([0,-1,0])

while stack:

  node=stack.pop()

  v=node[0]

  parent=node[1]

  point=node[2]

  point+=P[v]

  ans[v]=point

  children=E[v]

  for child in children:

    if child==parent:

      continue

    stack.append([child,v,point])

    

print((*ans))
N, Q = list(map(int, input().split()))
tree = {}
for i in range(N - 1):
    a, b = list(map(int, input().split()))
    if (a - 1) in tree:
        tree[a - 1].append(b - 1)
    else:
        tree[a - 1] = [b - 1]
    if (b - 1) in tree:
        tree[b - 1].append(a - 1)
    else:
        tree[b - 1] = [a - 1]
point = [0] * N
for i in range(Q):
    p, x = list(map(int, input().split()))
    point[p - 1] += x
ans = [0] * N
stack = []
stack.append([0, 0, -1])
while len(stack) > 0:
    nodes = stack.pop()
    node = nodes[0]
    sump = nodes[1]
    parent = nodes[2]
    sump = sump + point[node]
    ans[node] = sump
    if node in tree:
        childs = tree[node]
        for child in childs:
            if child != parent:
                stack.append([child, sump, node])
print((*ans))

N, Q = list(map(int, input().split()))
E = [[] for i in range(N)]
for i in range(N - 1):
    a, b = list(map(int, input().split()))
    a, b = a - 1, b - 1
    E[a].append(b)
    E[b].append(a)
P = [0] * N
for i in range(Q):
    p, x = list(map(int, input().split()))
    P[p - 1] += x
ans = [0] * N
stack = []
# 点,親,ポイント
stack.append([0, -1, 0])
while stack:
    node = stack.pop()
    v = node[0]
    parent = node[1]
    point = node[2]
    point += P[v]
    ans[v] = point
    children = E[v]
    for child in children:
        if child == parent:
            continue
        stack.append([child, v, point])
print((*ans))

-tree = {} +E = [[] for i in range(N)] -    if (a - 1) in tree: -        tree[a - 1].append(b - 1) -    else: -        tree[a - 1] = [b - 1] -    if (b - 1) in tree: -        tree[b - 1].append(a - 1) -    else: -        tree[b - 1] = [a - 1] -point = [0] * N +    a, b = a - 1, b - 1 +    E[a].append(b) +    E[b].append(a) +P = [0] * N -    point[p - 1] += x +    P[p - 1] += x -stack.append([0, 0, -1]) -while len(stack) > 0: -    nodes = stack.pop() -    node = nodes[0] -    sump = nodes[1] -    parent = nodes[2] -    sump = sump + point[node] -    ans[node] = sump -    if node in tree: -        childs = tree[node] -        for child in childs: -            if child != parent: -                stack.append([child, sump, node]) +# 点,親,ポイント +stack.append([0, -1, 0]) +while stack: +    node = stack.pop() +    v = node[0] +    parent = node[1] +    point = node[2] +    point += P[v] +    ans[v] = point +    children = E[v] +    for child in children: +        if child == parent: +            continue +        stack.append([child, v, point])