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
r=0..3
r.any?{|k|
r.all?{|m|z(a[m*2-2,2],a[m*2,2],a[m*2-2,2],b[k*2,2])<=0}||
r.all?{|m|z(b[m*2-2,2],b[m*2,2],b[m*2-2,2],a[k*2,2])<=0}||
r.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{m=gets.to_i
a=[*0..m-1]
l=a.map{gets.split.map &:to_i}
m.times{|i|(i+1..m-1).each{|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.each{|t|a[t]=k<j ?k:j})}}
p a.map{|i|i=a[i]while a[i]!=i;i}.uniq.size}end