import java.io.BufferedInputStream;
import java.util.Arrays;
import java.util.Scanner;
public class Main {
final static int N = 1010;//
// static float [] dp = new float [N];
static int [] height = new int [N];
static int [] l = new int [N];
static int [] r= new int [N];
// static float per[]=new float [N+1];
public static void main(String args[])
{
Scanner in = new Scanner(new BufferedInputStream(System.in));
int times=in.nextInt();
while(times!=0)
{
int m,n,i,res=0;
char [] s=new char[3];
m=in.nextInt();
n=in.nextInt();
Arrays.fill(height, 0);
for(int row=1;row<=m;row++)
{
for(int col=1;col<=n;col++)
{
s=in.next().toCharArray();
if(s[0]=='F')
height[col]++;
else {
height[col]=0;
}
}
for(i=1;i<=n;i++)
{
l[i]=i;
while(l[i]-1>=1&&height[l[i]-1]>=height[i])
l[i]=l[l[i]-1];
}
for(i=n;i>=1;i--)
{
r[i]=i;
while(r[i]+1<=n&&height[r[i]+1]>=height[i])
r[i]=r[r[i]+1];
}
res=-1;
for(i=1;i<=n;i++)
res=Math.max(res, (r[i]-l[i]+1)*height[i]);
}
System.out.println(3*res);
times--;
}
}
}
代码如上