n, m = gets.split.map(&:to_i)
students = n.times.map{gets.split.map(&:to_i)}
checks = n.times.map{|i| gets.split.map(&:to_i) << i+1}
students.each{|p|
	puts checks.min_by{|q| p.zip(q).map{|d| d.reduce(:-).abs}.reduce(:+)}[2]
}