You have been cast as the computer genius who cracks the case in the season finale of C.S.I.: P15. As expected, a camera feed shows up that needs to be analyzed. The camera records in HD-9000 quality with extra regression, the stream is then matched inside the camera by a re-inverted isomorphic bit coefficient matrix and plasma shifted five times for good measure. You view the feed through Netscape Navigator 4 Platinum Edition.
The trouble is that a saboteur switched the camera into ASCII mode and into picture burst mode. All you have left is a pile of still ASCII images. For reasons the show reveals later, you have to design and implement a deterministic algorithm that counts the flowers and the birds in one still image.
The rules of an image are these.
. (a dot).= characters only. Nothing else ever appears on that line.|, /, \, -, @ that is connected to the ground. A component is connected to the ground when one of its cells is 8-adjacent to a = cell of the last line./\/\ inside a single line whose four cells are surrounded exclusively by air, or by the edges of the image.So something that looks like a bird but sits on the ground is a flower. It may be an ex-parrot, but here it counts as a flower too.
The first line holds one integer T, the number of test cases. Each test case begins with a line of two integers separated by a space, the height H and the width W, and continues with H lines describing the picture. Each line of the picture has exactly W characters. All lines but the last consist of ., |, /, \, -, @ only, and the last line consists of = only.
For each test case, print two lines. If the number of flowers is F and the number of birds is B, print
Flowers: F
Birds: B