A solar field is a grid of R rows and C columns of heliostats. A cell holds 1 if that heliostat is working and 0 if it is broken. A commissioning team wants the largest square block of heliostats that are all working, so they can be aimed as one unit.
Determine the area (number of cells) of the largest axis-aligned square sub-block whose cells are all 1. If no cell is 1, the area is 0.
Input format
Line 1: two integers R and C.
Next R lines: each contains C integers, each 0 or 1.
Output format
A single integer: the area (side length squared) of the largest all-1 square, or 0 if there is none.
Constraints
- 1 <= R <= 100
- 1 <= C <= 100
- Each cell is 0 or 1.