cho.sh
Notes
Loading...

Largest Square

Time limit

1s

Memory limit

128 MB

Problem

You are given an n x m grid made of 0s and 1s. Find the largest-area square in the grid whose every cell is 1.

Print the area of the square, not its side length.

Input

The first line contains two integers n and m. (1 <= n, m <= 1,000)

Each of the next n lines contains one string of length m consisting only of 0s and 1s.

Output

Print the area of the largest square whose every cell is 1.