Humans have landed on a planet of the Centaurus constellation, and the planet is inhabited by monsters. The monsters' defense system is made of battle cells arranged as a matrix with N rows and M columns.
Our army has already destroyed some of the cells. Now it is your turn, and you destroy exactly one intact cell of your choice.
The strength of the defense system is the number of submatrices that contain only intact cells. Submatrices that overlap each other are counted separately. A submatrix is a nonempty matrix obtained from the original matrix by removing:
- some consecutive rows, starting from the first one,
- some consecutive rows, ending at the last one,
- some consecutive columns, starting from the first one,
- some consecutive columns, ending at the last one.
Pick the cell to destroy so that the strength of the defense system becomes as small as possible, and compute the strength after your attack.