n,k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
m = a.min
if m < k+1
    puts "-1"
    exit
end

puts n*(k+1)
for i in 0..k
    for j in 1..n
        print j,((i == k && j == n) ? "\n" : " ")
    end
end