var t:byte;
a:array [1..5000000] of byte;
q,q1,j,i,qq,n,s,k,l:longint;
Begin
assign(input,'f.dat');
reset(input);
assign(output,'f.sol');
rewrite(output);
read(t);
for i:=1 to t do begin
q:=0;
q1:=0;
s:=0;
read(n,qq);
for j:=1 to n do begin
read(a[i]);
if a[i]=1 then inc(q1)
else inc(q);
if q1>=q then inc(s);
end;
for k:=2 to n do begin
q:=0;
q1:=0;
for l:=k to n do begin
if a[l]=1 then inc(q1)
else inc(q);
if q1>=q then inc(s);
end;
end;
write(S,' ');
end;
close(input);
close(output);
end.