You are given a matrix with R rows and C columns. Every cell holds one integer, and you may apply the four operations below in any order, as many times as you like.
| Notation | Meaning |
|---|---|
rotR i k | Rotate row i to the right by k cells. (1≤i≤R, 1≤k<C) |
rotC j k | Rotate column j downward by k cells. (1≤j≤C, 1≤k<R) |
negR i | Multiply every element of row i by −1. (1≤i≤R) |
negC j | Multiply every element of column j by −1. (1≤j≤C) |
Applying each operation once to the matrix 147258369 gives the following results.
rotR 3 1 gives 149257368.rotC 1 2 gives 471258369.negR 2 gives 1−472−583−69.negC 2 gives 147−2−5−8369.Find the largest sum of all elements of the matrix that you can reach.
The first line contains two natural numbers R and C (1≤R,C≤100), separated by a space.
Each of the next R lines contains C integers separated by spaces. The absolute value of each integer is at most 104.
Print the largest reachable sum of all elements on the first line. Do not print the list of operations you used.