#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
  int n, m, s;
  double sx[501], sy[501], sz[501], tx, ty, tz, tr, u, v, w;
  bool f[501];

  while(cin>>n && n){
    s = 0;
    for(int i = 0; i < n; i++){
      cin >> sx[i] >> sy[i] >> sz[i];
      f[i] = true;
    }
    cin >> m;
    while(m--){
      cin >> tx >> ty >> tz >> tr;
      v = sqrt(tx*tx+ty*ty+tz*tz);

      for(int i = 0; i < n; i++){
	u = sqrt(sx[i]*sx[i]+sy[i]*sy[i]+sz[i]*sz[i]);
	w = tx*sx[i] + ty*sy[i] + tz*sz[i];

	if(acos(w/(v*u)) <= tr && f[i]){
	  s++;
	  f[i] = false;
	}
      }
    }

    cout << s << endl;
  }

  return 0;
}