SOLVE
LATER
Monk is fond of matrices. Today, he created a matrix A of size \(N \times 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)\) = \(\sum_{i=1}^{N} \sum_{j=1}^{M} abs(A[i][j])\)
where \(A[i][j]\) refers to the \(j^{th}\) cell in the \(i^{th}\) 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 \(j^{th}\) integer in the \(i^{th}\) 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 \le N \le 1000\)
\(1 \le M \le 1000\)
\(-10^9 \le A[i][j] \le 10^9\)
\(-10^9 \le v1,v2,v3,v4 \le 10^9\)
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\)