Roger, having now been bested twice in two dimensions, decides to move to three dimensions.
Roger has assembled a large block of stone, which has conveniently been subdivided into unit cubes that are either normal stones and paper. He challenges Victor to find a sub-block with a square base such that the entire sub-block contains no paper. The goal is to maximize the surface area of the components of the block perpendicular to one of the coordinate planes.
Constraints
Input Specification
The first line contains three integers, , , and .
lines follow, each containing characters. Character on line corresponds to the
cube that is located at , implying that all cubes lie in points where ,
, and . Each character is either N
for normal stone or P
for paper.
Output Specification
Output the maximum possible surface area of a valid block. In particular, the block must have dimensions for some positive and , and the answer to output should be . The orientation of the valid block need not be such that the square base is parallel to the -plane.
Sample Input
3 2 5
PNNNN
PNNNN
NPPNP
PNNNP
NNNNP
PPNNP
Sample Output
24
Comments