Stepan's House
Stepan recently acquired a plot of land in a prestigious area and plans to construct a modern house on it. The plot is a rectangle measuring N x M meters. According to the area's prestige regulations, the house must also be rectangular, with its walls parallel to the plot's sides. Additionally, the distance from any house wall to the nearest parallel boundary of the plot must be an integer number of meters. Naturally, Stepan aims to build a house with the largest possible area.
However, there is a challenge: two water wells are located on the plot. According to the same prestige rules, one well must be inside the house, while the other must remain outside its boundaries.
Your task is to help Stepan determine the maximum area of the house he can construct while complying with these prestige rules.
Input Format:
Consider Stepan's plot as being divided into 1 x 1 squares. Each well occupies one square, and they are located in different squares. The vertices of the house must align with the vertices of these squares.
The first line of the input contains two integers N, M (2 ≤ N, M ≤ 1000). Each of the following N lines contains M integers, representing the squares with 0 and 1. A 1 in a square indicates the presence of a well.
It is guaranteed that there are exactly two wells, meaning there are exactly two squares with a 1.
Output Format:
Output a single number – the maximum area of the house that Stepan can build while adhering to the prestige rules.