One is Good, but Two is Better

No attempts yetTime limit1sMemory limit128 MB

Problem

You are given an N×MN \times M matrix whose entries are each 00, 11, or 22. At least one entry equals 22.

Choose two axis-aligned rectangles (they may overlap, and they may even be identical) so that:

  • every cell equal to 22 lies inside at least one of the two rectangles, and
  • neither rectangle contains any cell equal to 11 (cells equal to 00 are allowed inside a rectangle).

The area of a rectangle is the number of cells it covers. Among all valid choices, minimize the area of the region covered by the two rectangles together (a cell covered by both rectangles is counted once).

Report that minimum combined area, or report that no valid pair of rectangles exists.

Input

The first line contains two integers NN and MM. Each of the next NN lines contains MM integers, giving the matrix row by row; every value is 00, 11, or 22.

Output

Print a single integer: the minimum combined area of the two rectangles, or 1-1 if no valid pair exists.

Constraints

  • 1N,M501 \le N, M \le 50
  • Every matrix entry is 00, 11, or 22.
  • At least one entry equals 22.