P12512 [AOJ] Compile
普及
题目描述

Masa Kita, who entered the University of Tokyo, joined a circle called TSG (University of Tokyo Super Gamers).

This circle exhibits games at the Komaba Festival every year, and Masa Kita decided to create and display the games as well.

The game created by Kitamasa is a common falling block puzzle game such as the following.

  • There is a grid-like field of 6 squares x 12 squares, and one block can be placed for each square.
  • Two blocks fall from the top in pairs. There are a total of 6 types of blocks, including basic blocks in 5 colors of red, green, blue, yellow, and purple, and obstructive blocks. The player can change the drop position by rotating and laterally moving the block.
  • When a falling block collides with the floor of the field or another block, the block is fixed at that position.
  • If there are blocks of the same color as the fixed block in four directions around them, they will stick to each other. However, the disturbing blocks do not stick to each other.
  • If 4 or more blocks stick together, it will disappear and you will get a score. When the basic blocks that exist in the four directions around the disturbing block disappear, the disturbing block also disappears. The disappearance of blocks occurs at the same time when all the blocks have finished falling.
  • When a block disappears, the block above it will fall. The player cannot control the fall of this block. At this time, if four or more blocks stick together again, they disappear and a chain occurs. However, even if multiple colors are erased at the same time, it will be treated as one chain.

Kitamasa finished writing most of the programs for this game, but couldn't write what to do when the blocks stuck together and disappeared. So I decided to ask a friend of the circle to write the program for that part.

Notes on Test Cases

Multiple datasets are given in the above input format.

The first line of input is given the number T of the dataset.

Create a program that outputs each data set in the above output format.

输入格式

见题面

输出格式

见题面

样例输入
3 ...... ...... ...... ...... ...... ...... ...... ...... .RGB.. RGOP.. RGBPB. RGBPP. GBRGYP GBRRYP BGGRBB BPRGYY GGPRRY BYPPRB YGGGPB GYYYPR YRBRBR YBRBRB BRBRBR BRBRBR ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ..OO.. ..OO..
样例输出
3 18 0