#C789. Maximal Square

    ID: 51810 Type: Default 1000ms 256MiB

Maximal Square

Maximal Square

You are given a binary matrix with dimensions \(n \times m\) where each element is either '0' or '1'. Your task is to find the area of the largest square sub-matrix that contains only '1's.

The area of a square with side length \(s\) is given by \(s^2\). For example, if the maximum side length you can achieve is \(2\), then the area of the square is \(2^2=4\).

Read the input from stdin and output the answer to stdout.

inputFormat

The first line of input contains two integers \(n\) and \(m\) separated by space, where \(n\) is the number of rows and \(m\) is the number of columns of the matrix.

Each of the following \(n\) lines contains a string of length \(m\) comprised solely of the characters '0' and '1'.

outputFormat

Output a single integer representing the area of the largest square sub-matrix that contains only '1's. The output should be written to stdout.

## sample
4 5
10100
10111
11111
10010
4