#include <cstdio>
#include <vector>
#include <cmath>
using namespace std;


struct point3{
	double x, y, z;
	point3(double x, double y, double z): x(x), y(y), z(z) {}
};

double dot(const point3 &p1, const point3 &p2){
	return p1.x * p2.x + p1.y * p2.y + p1.z * p2.z;
}

double abs(const point3 &p1){
	return sqrt( dot(p1, p1) );
}


int main(){
	int n, m;
	double x, y, z;
	while( scanf("%d", &n), n != 0 ){
		vector<point3> s, t;
		s.reserve(n);
		
		for(int i = 0; i < n; ++i){
			scanf("%lf%lf%lf", &x, &y, &z);
			s.push_back( point3(x, y, z) );
		}

		scanf("%d", &m);
		t.reserve(m);
		vector<double> phi(m);
		for(int i = 0; i < m; ++i){
			scanf("%lf%lf%lf%lf", &x, &y, &z, &phi[i]);
			t.push_back( point3(x, y, z) );
		}
		
		int cnt = 0;
		for(int i = 0; i < n; ++i){
			for(int j = 0; j < m; ++j){
				double theta = acos( dot(s[i], t[j]) / abs(s[i]) / abs(t[j]) );
				if( theta < phi[j] ){
					++cnt;
					break;
				}
			}
		}
		printf("%d\n", cnt);
	}
}