var
n,i,j,x,y:longint;
s,a:array[0..999] of longint;
begin
assign(input,'table2.in');
reset(input);
assign(output,'table2.out');
rewrite(output);
read(n);
for i:=1 to n do
begin
read(a[i]);
for j:=1 to a[i] do
begin
read(x,y);
if sqr(x-30)+sqr(y-30)<400 then s[i]:=s[i]+1;
if sqr(x-100)+sqr(y-30)<100 then s[i]:=s[i]+2;
if sqr(x-170)+sqr(y-30)<25 then s[i]:=s[i]+3;
end;
end;
for i:=1 to n do
writeln(s[i]);
close(input);
close(output);
end.