Homework
Petya isn't fond of doing homework, so he enlists the help of the top students in his class, offering them chocolate candies in exchange. Since Petya's father works at a chocolate factory, he always has an ample supply of candies. However, these top students are selective and demand a different number of candies each day to complete the homework. For each top student, Petya knows how many candies he needs to give on the i-th day of school for them to do his homework. Additionally, not every top student is willing to do Petya's homework every day. Petya is aware of the maximum number of consecutive days each top student is willing to help him.
Your task is to create a program that, given the number of candies required by each top student and the maximum number of consecutive days they are willing to work, calculates the minimum number of candies Petya needs to ensure all his homework is completed.
Input
The first line of the input contains two numbers: n — the number of consecutive school days Petya needs help with his homework, and m — the number of top students in his class (1 ≤ n ≤ 100, 2 ≤ m ≤ 100). The second line contains m integers a_i (1 ≤ i ≤ m), where each integer represents the maximum number of consecutive assignments each top student is willing to do for Petya (1 ≤ a_{i} ≤ n). The following m lines each contain n non-negative integers, where the j-th number in the i-th line indicates the number of candies Petya must give to the i-th top student to do his homework on the j-th day. All these numbers are no greater than 10^6. The numbers in each line are separated by spaces.
Output
On the first line of the output, print a single number — the minimum number of candies Petya needs. On the second line, print n integers, each indicating which top student should complete the homework for Petya on that day.