var
a,b,c,d,e,f,g,h,i,j,k,l,m,n:longint;
begin
assign(input,'table2.in');
reset(input);
assign(output,'table2.out');
rewrite(output);
read(a);
for b:=1 to a do
begin
read(c);
for d:=1 to c do
begin
read(e,f);
if e<=50 then if sqrt((abs(e-30))*(abs(e-30))+(abs(f-30))*(abs(f-30)))<20 then
g:=g+1 ;
if (e>=90)and(e<=110) then if sqrt((abs(e-100))*(abs(e-100))+(abs(f-30))*(abs(f-30)))<10 then
g:=g+2 ;
if (e>=165)and(e<=175) then if sqrt((abs(e-170))*(abs(e-170))+(abs(f-30))*(abs(f-30)))<5 then
g:=g+3;
e:=0;f:=0;
end;
writeln(g);g:=0;end;
close(input);
close(output);
end.