#include<cmath>
#include<cstdio>

#define	rep(i,n)	for(int i=0;i<n;i++)

using namespace std;

const double EPS=1e-9;

double dis2(double x,double y,double z){ return x*x+y*y+z*z; }

int main(){
	for(int n;scanf("%d",&n),n;){
		double sx[500],sy[500],sz[500];
		rep(i,n)	scanf("%lf%lf%lf",sx+i,sy+i,sz+i);
		int m;	scanf("%d",&m);
		double tx[50],ty[50],tz[50],phi[50];
		rep(i,m)	scanf("%lf%lf%lf%lf",tx+i,ty+i,tz+i,phi+i);

		int cnt=0;
		rep(i,n){
			bool looked=false;
			double a2=dis2(sx[i],sy[i],sz[i]);
			rep(j,m){
				double b2=dis2(tx[j],ty[j],tz[j]);
				double c2=dis2(sx[i]-tx[j],sy[i]-ty[j],sz[i]-tz[j]);
				double theta=acos((a2+b2-c2)/(2*sqrt(a2*b2)));	// law of cosines
				if(theta<phi[j]-EPS){ looked=true; break; }
			}
			cnt+=looked;
		}
		printf("%d\n",cnt);
	}

	return 0;
}