program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
 f:text;
 I,N,J:INTEGER;
 C:CHAR;
 X,Y,S,B,G,K:INTEGER;
 M:ARRAY[1..10,1..10] OF CHAR;
 NO,YES:INTEGER;
begin
 assign(f,'PARTY.IN');
 RESET(F);
 READ(F,N);
 FOR I:=1 TO N DO BEGIN
  s:=0;
  READLN(F,B,G,K);
  FOR X:= 1 TO 10 DO BEGIN
   FOR J:= 1 TO 10 DO BEGIN
    M[X,Y]:=' ';
   END;
  END;
  FOR X:= 1 TO B DO BEGIN
    FOR Y:= 1 TO G DO BEGIN
     READ(F,C);
     M[X,Y]:=C;
    END;
   READLN(F);
  END;

  {S:=B*G*2;
             }
             NO:=0;
             YES:=0;
//  S:=B*G*2;
  FOR X:= 1 TO B DO BEGIN
   FOR Y:= 1 TO G DO BEGIN
    IF M[X,Y]='N' then NO:=N+1;
    IF M[X,Y]='Y' THEN YES:=YES+1;

   END;
  END;

  IF NO=0 THEN S:=B*G*2;
  IF NO<> 0 THEN S:=S*B*2-NO;
  S:=ABS(S);
  writeln(s);

  S:=0;
 END;



 CLOSE(F);
end.
