#include <stdio.h>
#include <math.h>

typedef struct {
	double x,y,z;
	int seen;
} star_t;

int star_num;
star_t stars[500];

int main(void) {
	int boenkyo_num;
	double bx,by,bz,br;
	double cosine;
	int i,j;
	int count;
	while(1) {
		scanf("%d",&star_num);
		if(star_num==0)break;
		for(i=0;i<star_num;i++) {
			scanf("%lf%lf%lf",&stars[i].x,&stars[i].y,&stars[i].z);
			stars[i].seen=0;
		}
		scanf("%d",&boenkyo_num);
		count=0;
		for(i=0;i<boenkyo_num;i++) {
			scanf("%lf%lf%lf%lf",&bx,&by,&bz,&br);
			for(j=0;j<star_num;j++) {
				if(stars[j].seen)continue;
				cosine=(stars[j].x*bx+stars[j].y*by+stars[j].z*bz)/
					sqrt(stars[j].x*stars[j].x+stars[j].y*stars[j].y
						+stars[j].z*stars[j].z)/
					sqrt(bx*bx+by*by+bz*bz);
				if(cosine>=cos(br)) {
					stars[j].seen=1;
					count++;
				}
			}
		}
		printf("%d\n",count);
	}
	return 0;
}