Largest Free Block in a Rack Grid
A data hall is laid out as a grid of R rows and C slots per row. Every slot is either occupied (#) or free (.). A new tenant wants to install one rack cluster as a single contiguous rectangular block, so the whole block must land on free slots only.
Find the axis-aligned rectangle of free slots with the largest possible area (every slot inside it must be .). If several rectangles tie for the largest area, report the one whose top-left corner is topmost (smallest row), breaking further ties by the leftmost column; if a rectangle's top-left corner is still tied with another's, prefer the one with the smaller bottom row, and finally the smaller bottom-right column. In other words, among all rectangles of maximum area, output the one whose (top row, left column, bottom row, right column) tuple is smallest in that reading order.
Input
The first line contains two integers R and C (1 ≤ R, C ≤ 2000, R·C ≤ 4·10^6) — the number of rows and the number of slots per row.
Each of the next R lines contains a string of exactly C characters, each either . (free) or # (occupied).
Output
If at least one slot is free, print five integers separated by spaces: the maximum area, the 1-indexed row and column of the top-left corner of an optimal rectangle, and the 1-indexed row and column of its bottom-right corner — in the order area r1 c1 r2 c2. Use the tie-break rule above to choose among rectangles of maximum area.
If every slot is occupied, print a single 0.
Notes
In the first example, rows 1–5 are all free in columns 4–5 (the # blocks only ever appear in columns 2–3 or column 3), giving a 5×2 block of area 10, which beats every single row's run of free slots.
In the second example, the 2×2 block of free slots in the top-left corner and the 2×2 block in the bottom-right corner both have area 4. The tie-break rule picks the top-left one, since its top-left corner is topmost and leftmost.