n = gets.to_i
m = gets.to_i
target = gets.chomp.split.map(&:to_i)
score = Array.new(n, 0)
m.times{|game|
    vote = gets.chomp.split.map(&:to_i)
    vote.each_with_index{|v, i| score[i] +=1 if v == target[game]}
    score[target[game] - 1] += n - vote.count(target[game])
}
puts score
