People do strange things. Lately, some folks have taken to building structures out of Stick-Tite blocks ("They stick ... tight!"), pressing them between two sheets of perspex, and dunking them in water.
Yeah, we don't get it either.
A Stick-Tite block is a one-inch cube of a material that lets air pass through but not water. The blocks stick nicely to one another when properly aligned, so it is delightfully easy to build any kind of pixel-like structure. They also stick well (but not too well) to perspex.
When the construction is dunked underwater and shaken about, water fills every open space, except any region that is completely sealed off inside the construction. Water can flow between two open cells whenever they are orthogonally or diagonally adjacent.
X..
.X.
..X
Water can flow between the top-right and bottom-left regions.
X..
XXX
...
Water cannot flow between the top-right and bottom-left regions.
In the first construction above, water reaches the top region through the diagonal gaps. In the second, the two regions stay separated unless they connect somewhere else.
After being dunked and wiggled, the construction is pulled straight up out of the water. Water then drains out through any holes in the bottom or the sides, emptying every internal chamber and passage until the water level is even with the bottom of the holes in the chamber walls. Because of static water pressure, the level of any pool that is still connected after draining never rises above the bottom of the lowest hole its water can flow out of.
XXXXXXXXXXX
XX......XXX
XXX.XXXXX.X
X...X.XXXXX
X.X.X...X.X
X.X~X~X.X.X
X.X~~~X...X
X.XXXXXXX.X
Above, the tildes mark the greatest amount of water the central pool can hold. The hole on the left side is one unit higher than the one on the right, but the pool's level can rise no higher than the lower (right) hole. Draining a pool may split it into smaller, independent pools, and each of those then drains on its own.
XXXXXXXXXXX
X......X..X
X.XXXX~X..X
X.X~~~~X...
X~XXXXXX~~X
X~~~~~~X~~X
X~~~~~~~~~X
XXXXXXXXXXX
A construction holds a different amount of water depending on which way up it is dunked. Given the blocks that make up a construction, determine how much water it can hold when dunked with each of its four edges facing straight up. (The construction is dried out completely between dunkings.)
The first line contains a single integer $N$ ($1 \le N \le 100$), the number of data sets. Each data set consists of the following:
X is a Stick-Tite block and . is an open space.For each data set, print a single line containing four space-separated integers, sorted from highest to lowest: the number of cubic inches of water the construction can hold after being submerged and drained four times, once with each of its four edges facing straight up.