def dd
	n,q = gets.chomp.split(/\s/).map{|x| x.to_i}

    ab = []
    while cd = gets#.chomp.split(/\s/).map{|x| x.to_i}
        ab.push(cd.chomp.split(/\s/).map{|x| x.to_i})
    end
    px = ab.slice!(-q..-1)
    #p ab
    #p px

    aabb = Hash.new
    ab.each do |aaabbb|
        if aabb.has_key?(aaabbb[0])
            aabb[aaabbb[0]].push(aaabbb[1])
        else
            aabb[aaabbb[0]] = [0, aaabbb[1]]
        end

        unless aabb.has_key?(aaabbb[1])
            aabb[aaabbb[1]] = [0]
        end
    end

    px.each do |pppxxx|
        aabb[pppxxx[0]][0] += pppxxx[1]
    end

    #p aabb

    for i in 1..n
        x = aabb[i][0]
        #p aabb[i]
        for c in 1..(aabb[i].length-1)
            #puts aabb[i][c]
            aabb[aabb[i][c]][0] += x
        end
    end

    for i in 1..n
        print aabb[i][0].to_s + (i==n ? "" : " ")
    end
    puts
end

dd
