Monk is fond of matrices. Today, he created a matrix A of size N×M. He defines four types of operations on the matrix as follows:
Add v1 to all elements of a row.
Update the value of all elements of a row to v2, i.e., all elements of that row become equal to v2.
Add v3 to all elements of a column.
Update the value of all elements of a column to v4, i.e., all elements of that column become equal to v4.
He defines a function F(x) as
F(x) = ∑Ni=1∑Mj=1abs(A[i][j])
where A[i][j] refers to the jth cell in the ith row of matrix A, and abs(x) refers to absolute value of any integer x.
Now, he has defined some restrictions:
On any cell of the matrix, at most one operation can be performed. This operation can be of any type.
Any type of operation can be used any number of times.
You need to maximize the value of F(x) following these restrictions.
Input Format:
The first line consists of two integers N and M, denoting the number of rows and number of columns in matrix A respectively.
Each of the following N lines consist of M space-separated integers, where the jth integer in the ith line denotes A[i][j].
The last line of input consists of four space-separated integers denoting the values of v1,v2,v3 and v4 respectively.
Output Format:
The only line of output should consist of the maximum value of F(x).
Input Constraints:
1≤N≤1000
1≤M≤1000
−109≤A[i][j]≤109
−109≤v1,v2,v3,v4≤109
We use third type of operation on column 2 (or we can leave column 2 as it is) and fourth type of operation on column 1.
So, F(x) = abs(6)+abs(8−1)+abs(6)+abs(−9−1) = 6+7+6+10 = 29