def z a,b,c,d,e,f;(c-a)*(f-b)-(e-a)*(d-b)end
def x a,b;(0..3).any?{|k|r=(0..3).map{|m|z *a[m*2,2],*a[m*2-2,2],*b[k*2,2]};r.all?{|m|m>=0}||r.all?{|m|m<=0}}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=[]
i=a[i]while(b<< i;a[i]!=i)
j=a[j]while(b<< j;a[j]!=j)
b.map{|k|a[k]=[i,j].min})}}
a.map!{|i|i=a[i]while a[i]!=i;i}
p a.uniq.size}end