Buggy python submission (verdict: Time Limit Exceeded):
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n,q = readInts()
G = [[] for _ in range(n)]
for i in range(n-1):
    a,b = map(lambda x: int(x) - 1,input().split())
    G[a].append(b)
    G[b].append(a)
val = [0] * n
for i in range(q):
    p,x = readInts()
    p -= 1
    val[p] += x

def dfs(v,p):
    if p != -1:
        val[v] += val[p]
    for nv in G[v]:
        if nv == p:
            continue
        dfs(nv,v)

dfs(0,-1)
print(*val)


Fixed submission:
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n,q = readInts()
G = [[] for _ in range(n)]
for i in range(n-1):
    a,b = map(lambda x: int(x) - 1,input().split())
    G[a].append(b)
    G[b].append(a)
val = [0] * n
for i in range(q):
    p,x = readInts()
    p -= 1
    val[p] += x
stack = [(0,-1)]
while stack:
    v,p = stack.pop()
    for nv in G[v]:
        if nv == p:
            continue
        val[nv] += val[v]
        stack.append((nv,v))
# def dfs(v,p):
#     if p != -1:
#         val[v] += val[p]
#     for nv in G[v]:
#         if nv == p:
#             continue
#         dfs(nv,v)
#
# dfs(0,-1)
print(*val)

Buggy python submission (verdict: Runtime Error):
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n,q = readInts()
G = [[] for _ in range(n)]
for i in range(n-1):
    a,b = map(lambda x: int(x) - 1,input().split())
    G[a].append(b)
    G[b].append(a)
val = [0] * n
for i in range(q):
    p,x = readInts()
    p -= 1
    val[p] += x

def dfs(v,p):
    if p != -1:
        val[v] += val[p]
    for e in G[v]:
        if e == p:
            continue
        dfs(e,v)

dfs(0,-1)
print(*val)


Fixed submission:
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n,q = readInts()
G = [[] for _ in range(n)]
for i in range(n-1):
    a,b = map(lambda x: int(x) - 1,input().split())
    G[a].append(b)
    G[b].append(a)
val = [0] * n
for i in range(q):
    p,x = readInts()
    p -= 1
    val[p] += x
stack = [(0,-1)]
while stack:
    v,p = stack.pop()
    for nv in G[v]:
        if nv == p:
            continue
        val[nv] += val[v]
        stack.append((nv,v))
# def dfs(v,p):
#     if p != -1:
#         val[v] += val[p]
#     for nv in G[v]:
#         if nv == p:
#             continue
#         dfs(nv,v)
#
# dfs(0,-1)
print(*val)

Buggy python submission (verdict: Time Limit Exceeded):
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n,q = readInts()
G = [[] for _ in range(n)]
for i in range(n-1):
    a,b = map(lambda x: int(x) - 1,input().split())
    G[a].append(b)
    G[b].append(a)
val = [0] * n
for i in range(q):
    p,x = readInts()
    p -= 1
    val[p] += x

def dfs(v,p,val):
    if p != -1:
        val[v] += val[p]
    for e in G[v]:
        if e == p:
            continue
        dfs(e,v,val)

dfs(0,-1,val)
print(*val)


Fixed submission:
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n,q = readInts()
G = [[] for _ in range(n)]
for i in range(n-1):
    a,b = map(lambda x: int(x) - 1,input().split())
    G[a].append(b)
    G[b].append(a)
val = [0] * n
for i in range(q):
    p,x = readInts()
    p -= 1
    val[p] += x
stack = [(0,-1)]
while stack:
    v,p = stack.pop()
    for nv in G[v]:
        if nv == p:
            continue
        val[nv] += val[v]
        stack.append((nv,v))
# def dfs(v,p):
#     if p != -1:
#         val[v] += val[p]
#     for nv in G[v]:
#         if nv == p:
#             continue
#         dfs(nv,v)
#
# dfs(0,-1)
print(*val)