Farmer John wants to draw a map of his land, which is divided into rectangular fields. Each field is colored with a number (an integer in [1..1,000,000]). His goal is to design a map in which every adjacent pair of fields is colored differently.
Unfortunately, Farmer John's land is described in a rather unusual manner. His entire farm is a square, 1 kilometer on a side. The description of the layout of his farm is given by a sequence of lines, each of which contains one word or number per line.
The 1-by-1 kilometer square comprising the entire farm is described in the file as a series of one or more regions. A region can be specified by either:
There are no more than 100 regions on Farmer John's property.
Your task is to determine the greatest number of adjacent regions colored with the same color.
As above, a series of lines containing a number, the string 'hsplit', or the string 'vsplit'.
A single line with an integer that tells the greatest number of adjacent fields have the same color.
The farm would resemble something like this:
+----------+------+-----+
| | | |
| | | |
| | | |
| | 37 | 6 |
| | | |
| | | |
| 5 +------+-----+
| | |
| | |
| | 5 |
| | |
| | |
| | |
+----------+------------+