Bob is a strategy game programming specialist. In his new city building game the gaming environmentis as follows: a city is built up by areas, in which there are streets, trees, factories and buildings. Thereis still some space in the area that is unoccupied. The strategic task of his game is to win as muchrent money from these free spaces. To win rent money you must erect buildings, that can only berectangular, as long and wide as you can. Bob is trying to find a way to build the biggest possiblebuilding in each area. But he comes across some problems — he is not allowed to destroy alreadyexisting 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 rentpaid 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 ofthe areas is rectangular and has a different grid size with its own length M and width N. The existingoccupied units are marked with the symbol ‘R’. The unoccupied units are marked with the symbol ‘F’.

Input

The first line of the input file contains an integer K — determining the number of datasets. Next linescontain the area descriptions. One description is defined in the following way: The first line containstwo integers-area length M ≤ 1000 and width N ≤ 1000, separated by a blank space. The next Mlines contain N symbols that mark the reserved or free grid units, separated by a blank space. Thesymbols used are:R - reserved unitF - free unitIn the end of each area description there is a separating line.

Output

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

Sample Input

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

Sample Output45

0

//题意:

给你一个由F和R组成的矩阵,R为障碍,F为空地,让你找出一个面积最大的矩形,再将其面积*3的值输出。

/*
思路:
up[i][j]数组用来存放在第i行第j列位置处复合条件的竖直高度(矩形的高)
l[i][j]数组用来存放在第i行第j列位置处可以到达的最左端(矩形的长的左端点)
r[i][j]数组用来存放在第i行第j列位置处可以到达的最右端(矩形的长的右端点)
所以在第i行第j列位置处矩形的最大面积为up[i][j]*(r[i][j]-l[i][j]+1)。
遍历求出最大值即可。
*/

#include<stdio.h>
#include<string.h>
#include<algorithm>
#define INF 0x3f3f3f3f
#define N 1010
#define ll long long
using namespace std;
char s[N][N];
int map[N][N],up[N][N],l[N][N],r[N][N]; 
int main()
{
	int t,n,m,i,j,k;
	scanf("%d",&t);
	while(t--)
	{
		scanf("%d%d",&m,&n);
		for(i=0;i<m;i++)
		{
			for(j=0;j<n;j++)
			{
				int c=getchar();
				while(c!='F'&&c!='R')
					c=getchar();
				map[i][j]=c=='F'?0:1;
			}
		} 
		int ans=0;
		for(i=0;i<m;i++)
		{
			int lo=-1,ro=n;
			for(j=0;j<n;j++)
			{
				if(map[i][j]==1)
				{
					up[i][j]=l[i][j]=0;
					lo=j;
				}
				else
				{
					up[i][j]=i==0?1:up[i-1][j]+1;
					l[i][j]=i==0?lo+1:max(l[i-1][j],lo+1);
				}
			}
			for(j=n-1;j>=0;j--)
			{
				if(map[i][j]==1)
				{
					r[i][j]=n;
					ro=j;
				}
				else
				{
					r[i][j]=i==0?ro-1:min(r[i-1][j],ro-1);
					ans=max(ans,up[i][j]*(r[i][j]-l[i][j]+1));
				}
			}
		}
		printf("%d\n",ans*3);
	}
	return 0;
}