Олимпиадный тренинг

Задача 37083. Replacing a column with array elements


Given a matrix of size NxM and an array of numbers of size N. In this matrix, replace all elements of the column with the maximum sum of elements with elements of the given array of numbers. If there are several such columns, then replace the elements in the column with the lower index.

Input
The first line contains numbers N and M (\(0<N,M<=10\)) . Next come N lines of M numbers each. Each modulo number is no more than 100. The last line contains N array numbers.

Imprint 
Display the transformed matrix, allocating three character spaces for each element. Each number must be followed by a space character.
 
Example
# Input Output
1 3 4
52 16 61 93 
5 5 33 41 
37 34 14 16 
76 69 26
 52 16 61 76
  5 5 33 69
 37 34 14 26

Запрещенные операторы:sum;max;min