char T[99][99]={"OUT OF MAIN PANEL"};
X[99],Y[99],V[99],W[99],c[99],w;
P(p,d){
	for(c[p]=0;scanf("%[^/>]>%d,%d,%d,%d<",T[w],X+w,Y+w,V+w,W+w)&&scanf("%*[^>]>%[<]",&d,c[p]++,P(w++)););
}
main(n,x,y,i){
	for(;scanf("%d\n<",&n)*n;)
		for(w=1,P(0);n--;printf("%s %d\n",T[i],c[i]))
			for(scanf("%d%d",&x,&y),i=w;--i&&x<X[i]|y<Y[i]|x>V[i]|y>W[i];);
}