Balancing the Matrix#3666

Balancing the Matrix

1 second
256 megabytes
Very hard

Given a matrix of dimensions M \times N, you are allowed to perform the following operation: select any element from the matrix and either increase or decrease it by . You must perform exactly such operations. The objective is to make the elements within each row as similar as possible. Additionally, you need to minimize the value represented by the following expression:

Input

The first line of the input contains two integers, and (1 \leq M, N \leq 1000). The next lines each contain integers, which define the matrix . Each of these integers is within the range of -10^9 to 10^9. The final line contains an integer (0 \leq K \leq 10^{18}).

Output

On the first line of the output, print the minimum value that can be achieved after performing operations. In the subsequent lines, print the resulting matrix.

Examples

Example 1

Loading
Loading