Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys


def solve(N: int, Q: int, a: "List[int]", b: "List[int]", p: "List[int]", x: "List[int]"):
    edges = [set() for i in range(N+1)]
    score = [0] * (N+1)

    for i in range(N-1):
        edges[a[i]].add(b[i])

    for i in range(Q):
        # print(p[i], [z for z in edges[p[i]] if z > p[i]], x[i])
        # すべての以下のものに配布されるようにする
        tl = [p[i]]
        al = {p[i]}
        while(len(tl) != 0):
            t = tl.pop(0)
            tl += edges[t]
            al |= set(tl)
        for y in al:
            score[y] += x[i]

    print(' '.join(map(str,score[1:])))

    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    Q = int(next(tokens))  # type: int
    a = [int()] * (N-1)  # type: "List[int]" 
    b = [int()] * (N-1)  # type: "List[int]" 
    for i in range(N-1):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    p = [int()] * (Q)  # type: "List[int]" 
    x = [int()] * (Q)  # type: "List[int]" 
    for i in range(Q):
        p[i] = int(next(tokens))
        x[i] = int(next(tokens))
    solve(N, Q, a, b, p, x)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys


def solve(N: int, Q: int, a: "List[int]", b: "List[int]", p: "List[int]", x: "List[int]"):
    dedges = [set() for i in range(N+1)]
    uedges = [set() for i in range(N+1)]
    score = [0] * (N+1)

    for i in range(N-1):
        dedges[a[i]].add(b[i])
        # uedges[b[i]].add(a[i])

    # 自分以下のすべての子ノードを記録するようにする
    for i in range(Q):
        score[p[i]] += x[i]

    for i in range(1, N+1):
        for j in dedges[i]:
            score[j] += score[i]

    print(' '.join(map(str, score[1:])))


    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    Q = int(next(tokens))  # type: int
    a = [int()] * (N-1)  # type: "List[int]" 
    b = [int()] * (N-1)  # type: "List[int]" 
    for i in range(N-1):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    p = [int()] * (Q)  # type: "List[int]" 
    x = [int()] * (Q)  # type: "List[int]" 
    for i in range(Q):
        p[i] = int(next(tokens))
        x[i] = int(next(tokens))
    solve(N, Q, a, b, p, x)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys


def solve(N: int, Q: int, a: "List[int]", b: "List[int]", p: "List[int]", x: "List[int]"):
    edges = [set() for i in range(N+1)]
    score = [0] * (N+1)

    for i in range(N-1):
        edges[a[i]].add(b[i])
        edges[b[i]].add(a[i])

    for i in range(Q):
        # print(p[i], [z for z in edges[p[i]] if z > p[i]], x[i])
        # すべての以下のものに配布されるようにする
        tl = [p[i]]
        al = set()
        al.add(p[i])
        while(len(tl) != 0):
            t = tl.pop(0)
            tl += [s for s in edges[t] if s > t]
            # print("tl", tl, set(tl))
            al = al | set(tl)
            # print("al", al)
        # print(p[i], al, x[i])
        for y in al:
            score[y] += x[i]

    print(' '.join(map(str,score[1:])))

    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    Q = int(next(tokens))  # type: int
    a = [int()] * (N-1)  # type: "List[int]" 
    b = [int()] * (N-1)  # type: "List[int]" 
    for i in range(N-1):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    p = [int()] * (Q)  # type: "List[int]" 
    x = [int()] * (Q)  # type: "List[int]" 
    for i in range(Q):
        p[i] = int(next(tokens))
        x[i] = int(next(tokens))
    solve(N, Q, a, b, p, x)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys


def solve(N: int, Q: int, a: "List[int]", b: "List[int]", p: "List[int]", x: "List[int]"):
    dedges = [set() for i in range(N+1)]
    uedges = [set() for i in range(N+1)]
    score = [0] * (N+1)

    for i in range(N-1):
        dedges[a[i]].add(b[i])
        # uedges[b[i]].add(a[i])

    # 自分以下のすべての子ノードを記録するようにする
    for i in range(Q):
        score[p[i]] += x[i]

    for i in range(1, N+1):
        for j in dedges[i]:
            score[j] += score[i]

    print(' '.join(map(str, score[1:])))


    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    Q = int(next(tokens))  # type: int
    a = [int()] * (N-1)  # type: "List[int]" 
    b = [int()] * (N-1)  # type: "List[int]" 
    for i in range(N-1):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    p = [int()] * (Q)  # type: "List[int]" 
    x = [int()] * (Q)  # type: "List[int]" 
    for i in range(Q):
        p[i] = int(next(tokens))
        x[i] = int(next(tokens))
    solve(N, Q, a, b, p, x)

if __name__ == '__main__':
    main()