You are given a grid of size . Each cell of the grid is colored in either white or black. You have to extract some subgrids out of the original grid. To extract these subgrids, you are required to follow these constraints:
The score of a subgrid is defined by the absolute difference between the count of white and black cells in it. Your task is to maximize the sum of the scores of all the selected subgrids. It is not necessary to select all the subgrids of the grid.
Input format
Output format
Note:
Constraints
Note: The input data contains only 50 percent of the original test data. The other data will be added after the contest and the submissions will be rejudged.
Verdict and scoring
If any of the grids overlap or the selected submatrix is not valid, then you will get a Wrong Answer verdict. For each of the valid output, your result is the sum of the scores of all the selected submatrices. Each submatrix score is the absolute difference of the count of black and white cells in it.
In the given sample if you pick the submatrices as shown in the output then your total score will be .