Gats and the String Forts
Gats has covered a rectangular rooftop with scratching posts. Every cell contains one post and some fish biscuits. The post at row and column has height , and its cell contains fish biscuits.
To build a fort centered at cell , Gats sends one string from that cell in each of the four cardinal directions. In each direction, the string passes over posts shorter than and attaches to the first post whose height is at least . If no such post exists before the edge of the grid, that string cannot attach.
A fort is valid only if all four strings attach. Suppose its upper and lower strings attach in rows and , while its left and right strings attach in columns and . The fort contains every cell satisfying
Thus, the center cell is included, while the four boundary lines are not. Every cell in this rectangle is included regardless of its post height.
The fish total of a fort is the sum of over all cells it contains. Determine the greatest fish total of any valid fort and how many different center cells produce that total.
Input
The first line contains two integers and , the number of rows and columns of the rooftop grid, respectively, where and .
Output
Print two integers and . The value is the greatest fish total among all valid forts, and is the number of centers whose forts have that total.
If there is no valid fort, print and .
Samples
Sample 1
Input
5 5 5 4 5 3 5 4 2 3 2 4 5 3 4 3 5 4 2 3 2 4 5 4 5 4 5 1 0 1 0 1 0 2 1 2 0 1 1 5 1 1 0 2 1 2 0 1 0 1 0 1
Output
17 1
The fort centered at row , column attaches to posts at , , , and . Its interior is a rectangle containing fish biscuits. It is the unique fort with the greatest total.