var
t,n,i,j,k,l:integer;
x,y:integer;
function check(a:integer):integer;
begin
if a=1 then
if (x-30)*(x-30)+(y-30)*(y-30)<400 then check:=1;
if a=2 then
if (x-100)*(x-100)+(y-30)*(y-30)<100 then check:=2;
if a=3 then
if (x-170)*(x-170)+(y-30)*(y-30)<25 then check:=3;
end;
begin
assign(input,'table2.in');reset(input);
assign(output,'table2.out');rewrite(output);
read(t);
for l:=1 to t do
begin
k:=0;
read(n);
for i:=1 to n do
begin
read(x,y);
if (x>10)and(x<50)and(y>10)and(y<50) then k:=k+check(1);
if (x>90)and(x<110)and(y>20)and(y<=40) then k:=k+check(2);
if (x>165)and(x<175)and(y>25)and(y<35) then k:=k+check(3);
end;
writeln(k);
end;
close(input);
close(output);
end.