//26
#include<iostream>
#include<cmath>

using namespace std;

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

int main(){
  for(int n;cin>>n,n;){
    double x[500],y[500],z[500];
    for(int i=0;i<n;i++){
      cin>>x[i]>>y[i]>>z[i];
    }
    int m;
    cin>>m;
    bool s[500]={};
    int ans=0;
    while(m--){
      double tx,ty,tz,an;
      cin>>tx>>ty>>tz>>an;
      for(int i=0;i<n;i++){
	double a,b,c;
	a=ds(tx-x[i],ty-y[i],tz-z[i]);
	b=ds(tx,ty,tz);
	c=ds(x[i],y[i],z[i]);
	if(acos((b*b+c*c-a*a)/b/c/2)<an){
	  ans+=!s[i];
	  s[i]=true;
	}
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}