N = gets.to_i
M = gets.to_i
A = gets.split.map(&:to_i).map{|i|i-1}
sum = Array.new(N){0}
M.times do |round|
  gets.split.map(&:to_i).map{|i|i-1}.each.with_index do |b, i|
    case A[round]
      when i
        sum[i] += 1
      when b
        sum[i] += 1
      else
        sum[A[round]] += 1
    end
  end
end
puts sum