N,Q=map(int,input().split())
A=[list(map(int,input().split())) for _ in range(N-1)]
A.sort()
 
cost=[0]*(N+1)
 
for _ in range(Q):
	a,b=map(int,input().split())
	cost[a]+=b
 
for a in A:
	cost[a[1]] += cost[a[0]]
print(*cost[1:])
N,Q=map(int,input().split())
A=[list(map(int,input().split())) for _ in range(N-1)]
A.sort()

cost=[0]*(N+1)

for _ in range(Q):
	a,b=map(int,input().split())
	cost[a]+=b

for a in A:
	cost[a[1]] += cost[a[0]]
print(*cost[1:])
