void multiset_delete_one(multiset<string>& S, string str ) { S.erase(S.find(str)); }
int main(){ int i,j,k,l,test,t=1; //freopen("in.txt","r",stdin); //freopen("out.txt","w",stdout); scanf("%d",&test); while(test--){ scanf("%d",&n); set1.clear(); printf("Case #%d:\n",t++); int li,ci; for(i=1;i<=n;i++){ scanf("%d %d",&li,&ci); pii now=mp(li,ci); if(set1.find(now)!=set1.end()){ set1.insert(now); printf("%d\n",set1.size()); continue; } //printf("\n%d %d\n",li,ci); while(set1.size()){ it=set1.upper_bound(now); //printf("it= %d-%d\n ",(*it).uu,(*it).vv); if(it==set1.end()){ break; } else if((*it).vv>=ci){ set1.erase(it); } else break; } it=set1.upper_bound(now); if(it==set1.begin()){ set1.insert(now); } else{ it--; if((*it).vv>ci){ set1.insert(now); } } for(it=set1.begin();it!=set1.end();it++){ // printf("%d-%d ",(*it).uu,(*it).vv); } //puts(""); printf("%d\n",set1.size()); continue; } if(test) puts(""); } return 0; }