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|
[[a,b],[b,a]].any?{|c,d|r.all?{|m|z(c[m-1],c[m],c[m-1],d[k])<=0}}||
r.any?{|m|xx a[k-1],a[k],b[m-1],b[m]}
}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).each_slice(2)]}
m.times{|i|(i+1..m-1).each{|j|x(l[i],l[j])&&(b=[]
k=[i,j].map{|t|t=a[t]while(b<< t;a[t]!=t);t}.min
b.each{|t|a[t]=k})}}
p a.map{|i|i=a[i]while a[i]!=i;i}.uniq.size}end