h,w=gets.split.map &:to_i
u=Array.new(h){Array.new(w)}
h.times do |y|
　w.times do |x|
  a=gets.to_i
  u[y-1][x-1] = a
end

h.times do |g|
 b=gets.to_i
 puts u[g-1][0]*b+u[g-1][1]*b+u[g-1][2]*b+u[g-1][3]*b
end
