var
 s:string;
 i,j,x,y,n,m,p,q,j2:integer;
 s1:int64;
function F(n:integer):longint;
var
 i,s:longint;
begin
 s:=1;
 for i:=1 to n do
  s:=s*i;
 F:=s;
end;
begin
 assign(input,'PARTY.IN'); reset(input);
 read(q);
 for j2:=1 to q do begin
 readln(n,m,p); x:=0; y:=0;  s1:=0;
 for i:=1 to n do begin
  readln(s); x:=0; y:=0;
 for j:=1 to length(s) do
  if s[j]='Y' then inc(y) else inc(x);
 s1:=s1+(F(y) div F(x));
 end;
 writeln(s1 div p);
 end;
end.
