def z a,b,c,d;(b[0]-a[0])*(d[1]-c[1])-(d[0]-c[0])*(b[1]-a[1])end
def xx a,b,c,d;(v=z a,b,c,d)!=0&&z(a,c,a,b)/v==0&&z(a,c,c,d)/v==0;end
def x a,b
(0..3).any?{|k|
(0..3).map{|m|z a[m*2-2,2],a[m*2,2],a[m*2-2,2],b[k*2,2]}.all?{|m|m<=0}||
(0..3).map{|m|z b[m*2-2,2],b[m*2,2],b[m*2-2,2],a[k*2,2]}.all?{|m|m<=0}||
(0..3).any?{|m|xx a[k*2-2,2],a[k*2,2],b[m*2-2,2],b[m*2,2]}
}end
while(n=gets.to_i)>0
n.times{a=[*0..gets.to_i-1]
l=a.map{gets.split.map &:to_i}
a.map{|i|(i+1..a[-1]).map{|j|x(l[i],l[j])&&(b=[]
k=i
k=a[k]while(b<< k;a[k]!=k)
j=a[j]while(b<< j;a[j]!=j)
b.map{|t|a[t]=[k,j].min})}}
a.map!{|i|i=a[i]while a[i]!=i;i}
p a.uniq.size}end