2348: Trundling Object

内存限制:128 MB 时间限制:1.000 S
评测方式:文本比较 命题人:
提交:1 解决:1

题目描述

There is a rectangular cube with dimensions a*b*c on a  m*n table (Face  a*b of the cube is on the first a rows and first  b columns of the table). Some of the cells of the table are blue and some are red(Some of the cells may have no color). You can trundle rectangular cube in one of the four directions up, down, left and right if: 

1. It completely remains on the table.

2. There will be no red cell under the cube.

When the rectangular cube covers a cell, the color of that cell will be change to black. You should find the maximum number of blue cells that can be change to black.

输入

First line of Input contains the number of the tests. 

Each test case consists of 1<=a,b,c<=100 that shows the dimensions of the cube and max(a,b,c)<=n,m<=100 that shows the size of table. In the following  m lines, in each line there are n  characters('B','R','.','.'represent no color cells) that show the colors of the cells of the table.

输出

For each test case, output the maximum number of blue cells that can be turn to black.

样例输入 复制

3
1 1 1
3 3
BRB
BRB
RRR
2 1 1
3 3
BRB
BBB
RRR
2 1 1
3 3
BRB
BBB
BBB

样例输出 复制

2
2
7

来源/分类