def get_answer(ki):

    n = ki[0][0]

    q = ki[0][1]

    #n_data = [[int(k[0]), int(k[1])] for k in [k.split(" ") for k in ki[1:-q]]]

    #q_data = [[int(k[0]), int(k[1])] for k in [k.split(" ") for k in ki[-q:]]]

    n_data = ki[1:-q]

    #q_data = ki[-q:]

    q_index = [0] * n

    for qq in ki[-q:]:

        q_index[qq[0] - 1] += qq[1]



    score = [0] * n



    """

        assert get_answer(["4 3",

                       "1 3", "1 4", "2 3",

                       "2 10", "1 100", "3 1"]) == "100 111 101 100"

    """

    t_index = []

    for i in range(0, n + 1):

        t_index.append([])

    for nn in n_data:

        t_index[nn[0]].append(nn[1])

        t_index[nn[1]].append(nn[0])



    t_stack = [1]

    s_stack = [0]

    r_flag = [0] * n

    while len(t_stack) > 0:

        i = t_stack.pop()

        s = s_stack.pop()

        if r_flag[i - 1]:

            continue

        r_flag[i - 1] = 1

        s += q_index[i - 1]

        score[i - 1] += s

        t_stack += t_index[i]

        s_stack += [s] * len(t_index[i])



    """

    s_value = str(score[0])

    for i in range(1, n):

        s_value += " " + str(score[i])

    """

    ss = [str(s) for s in score]

    return " ".join(ss)



# b05 1998 ms

if __name__ == "__main__":

    input_ki = []

    while True:

        try:

            input1 = eval(input())

            if not input1:

                break

            if len(input1) == 0:

                break

            s = input1.split(" ")

            input_ki.append([int(s[0]), int(s[1])])

        except EOFError:

            break

    print((get_answer(input_ki)))

def get_answer(ki):

    """

    n = ki[0][0]

    q = ki[0][1]

    n_data = ki[1:-q]

    q_index = [0] * n

    for qq in ki[-q:]:

        q_index[qq[0] - 1] += qq[1]

    """

    k0 = ki[0].split(" ")

    n = int(k0[0])

    q = int(k0[1])

    q_index = [0] * n

    for k in ki[-q:]:

        k = k.split(" ")

        q0 = int(k[0])

        q1 = int(k[1])

        q_index[q0 - 1] += q1



    score = [0] * n



    """

        assert get_answer(["4 3",

                       "1 3", "1 4", "2 3",

                       "2 10", "1 100", "3 1"]) == "100 111 101 100"

    """

    t_index = []

    for i in range(0, n + 1):

        t_index.append([])

    for ki_n in ki[1:-q]:

        k = ki_n.split(" ")

        n0 = int(k[0])

        n1 = int(k[1])

        t_index[n0].append(n1)

        t_index[n1].append(n0)



    t_stack = [1]

    s_stack = [0]

    r_flag = [0] * n

    while len(t_stack) > 0:

        i = t_stack.pop()

        s = s_stack.pop()

        if r_flag[i - 1]:

            continue

        r_flag[i - 1] = 1

        s += q_index[i - 1]

        score[i - 1] += s

        t_stack += t_index[i]

        s_stack += [s] * len(t_index[i])



    ss = [str(s) for s in score]

    return " ".join(ss)



# b05 1923 ms

if __name__ == "__main__":

    input_ki = []

    while True:

        try:

            input1 = eval(input())

            if not input1:

                break

            if len(input1) == 0:

                break

            #s = input1.split(" ")

            #input_ki.append([int(s[0]), int(s[1])])

            input_ki.append(input1)

        except EOFError:

            break

    print((get_answer(input_ki)))

def get_answer(ki):
    n = ki[0][0]
    q = ki[0][1]
    # n_data = [[int(k[0]), int(k[1])] for k in [k.split(" ") for k in ki[1:-q]]]
    # q_data = [[int(k[0]), int(k[1])] for k in [k.split(" ") for k in ki[-q:]]]
    n_data = ki[1:-q]
    # q_data = ki[-q:]
    q_index = [0] * n
    for qq in ki[-q:]:
        q_index[qq[0] - 1] += qq[1]
    score = [0] * n
    """
        assert get_answer(["4 3",
                       "1 3", "1 4", "2 3",
                       "2 10", "1 100", "3 1"]) == "100 111 101 100"
    """
    t_index = []
    for i in range(0, n + 1):
        t_index.append([])
    for nn in n_data:
        t_index[nn[0]].append(nn[1])
        t_index[nn[1]].append(nn[0])
    t_stack = [1]
    s_stack = [0]
    r_flag = [0] * n
    while len(t_stack) > 0:
        i = t_stack.pop()
        s = s_stack.pop()
        if r_flag[i - 1]:
            continue
        r_flag[i - 1] = 1
        s += q_index[i - 1]
        score[i - 1] += s
        t_stack += t_index[i]
        s_stack += [s] * len(t_index[i])
    """
    s_value = str(score[0])
    for i in range(1, n):
        s_value += " " + str(score[i])
    """
    ss = [str(s) for s in score]
    return " ".join(ss)


# b05 1998 ms
if __name__ == "__main__":
    input_ki = []
    while True:
        try:
            input1 = eval(input())
            if not input1:
                break
            if len(input1) == 0:
                break
            s = input1.split(" ")
            input_ki.append([int(s[0]), int(s[1])])
        except EOFError:
            break
    print((get_answer(input_ki)))

def get_answer(ki):
    """
    n = ki[0][0]
    q = ki[0][1]
    n_data = ki[1:-q]
    q_index = [0] * n
    for qq in ki[-q:]:
        q_index[qq[0] - 1] += qq[1]
    """
    k0 = ki[0].split(" ")
    n = int(k0[0])
    q = int(k0[1])
    q_index = [0] * n
    for k in ki[-q:]:
        k = k.split(" ")
        q0 = int(k[0])
        q1 = int(k[1])
        q_index[q0 - 1] += q1
    score = [0] * n
    """
        assert get_answer(["4 3",
                       "1 3", "1 4", "2 3",
                       "2 10", "1 100", "3 1"]) == "100 111 101 100"
    """
    t_index = []
    for i in range(0, n + 1):
        t_index.append([])
    for ki_n in ki[1:-q]:
        k = ki_n.split(" ")
        n0 = int(k[0])
        n1 = int(k[1])
        t_index[n0].append(n1)
        t_index[n1].append(n0)
    t_stack = [1]
    s_stack = [0]
    r_flag = [0] * n
    while len(t_stack) > 0:
        i = t_stack.pop()
        s = s_stack.pop()
        if r_flag[i - 1]:
            continue
        r_flag[i - 1] = 1
        s += q_index[i - 1]
        score[i - 1] += s
        t_stack += t_index[i]
        s_stack += [s] * len(t_index[i])
    ss = [str(s) for s in score]
    return " ".join(ss)


# b05 1923 ms
if __name__ == "__main__":
    input_ki = []
    while True:
        try:
            input1 = eval(input())
            if not input1:
                break
            if len(input1) == 0:
                break
            # s = input1.split(" ")
            # input_ki.append([int(s[0]), int(s[1])])
            input_ki.append(input1)
        except EOFError:
            break
    print((get_answer(input_ki)))

+    """ -    # n_data = [[int(k[0]), int(k[1])] for k in [k.split(" ") for k in ki[1:-q]]] -    # q_data = [[int(k[0]), int(k[1])] for k in [k.split(" ") for k in ki[-q:]]] -    # q_data = ki[-q:] +    """ +    k0 = ki[0].split(" ") +    n = int(k0[0]) +    q = int(k0[1]) +    q_index = [0] * n +    for k in ki[-q:]: +        k = k.split(" ") +        q0 = int(k[0]) +        q1 = int(k[1]) +        q_index[q0 - 1] += q1 -    for nn in n_data: -        t_index[nn[0]].append(nn[1]) -        t_index[nn[1]].append(nn[0]) +    for ki_n in ki[1:-q]: +        k = ki_n.split(" ") +        n0 = int(k[0]) +        n1 = int(k[1]) +        t_index[n0].append(n1) +        t_index[n1].append(n0) -    """ -    s_value = str(score[0]) -    for i in range(1, n): -        s_value += " " + str(score[i]) -    """ -# b05 1998 ms +# b05 1923 ms -            s = input1.split(" ") -            input_ki.append([int(s[0]), int(s[1])]) +            # s = input1.split(" ") +            # input_ki.append([int(s[0]), int(s[1])]) +            input_ki.append(input1)