CTGAME - City Game

题意翻译

鲍伯是一个战略游戏编程专家。在他的新城市建设游戏中,游戏环境如下:城市是由街道、树木、工厂和建筑物组成的区域。这个地区还没有空余的空间。他的游戏的战略任务是从这些自由空间中赢得尽可能多的租金。要赢得租金,你必须竖立建筑物,它只能是长方形的,尽可能长和宽。鲍伯正试图找到一种方法来建造每一个地区最大的建筑。但是他遇到了一些问题——他不被允许破坏他正在建设的地区已经存在的建筑物、树木、工厂和街道。 每个区域都有其宽度和长度。该地区被划分为等格子单位,你所建单位的租金为3美元。 你的任务是帮助鲍伯解决这个问题。整个城市分为K区。每个区域都是矩形的,并且具有不同的网格大小,其长度M和宽度N不同。现有的占用单元用符号R标记。未占用单元用符号F标记。

题目描述

Bob is a strategy game programming specialist. In his new city building game the gaming environment is as follows: a city is built up by areas, in which there are streets, trees, factories and buildings. There is still some space in the area that is unoccupied. The strategic task of his game is to win as much rent money from these free spaces. To win rent money you must erect buildings, that can only be rectangular, as long and wide as you can. Bob is trying to find a way to build the biggest possible building in each area. But he comes across some problems - he is not allowed to destroy already existing buildings, trees, factories and streets in the area he is building in. Each area has its width and length. The area is divided into a grid of equal square units.The rent paid for each unit on which you're building stands is 3$. Your task is to help Bob solve this problem. The whole city is divided into **K** areas. Each one of the areas is rectangular and has a different grid size with its own length **M** and width **N**. The existing occupied units are marked with the symbol **R**. The unoccupied units are marked with the symbol **F**.

输入输出格式

输入格式


The first line of the input contains an integer **K** - determining the number of datasets. Next lines contain the area descriptions. One description is defined in the following way: The first line contains two integers-area length **M**<=1000 and width **N**<=1000, separated by a blank space. The next **M** lines contain **N** symbols that mark the reserved or free grid units,separated by a blank space. The symbols used are: **R** - reserved unit **F** - free unit In the end of each area description there is a separating line.

输出格式


For each data set in the input print on a separate line, on the standard output, the integer that represents the profit obtained by erecting the largest building in the area encoded by the data set.

输入输出样例

输入样例 #1

2
5 6
R F F F F F
F F F F F F
R R R F F F
F F F F F F
F F F F F F

5 5
R R R R R
R R R R R
R R R R R
R R R R R
R R R R R

输出样例 #1

45
0