#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstdio>
using namespace std;
const double EPS = 1E-7;
int x,y,z,vx,vy,vz;
double bt[100001];
double et[100001];
int main()
{
int n,r;
cin>>n>>r;
for (int i=0;i<n;i++)
{
scanf("%d%d%d",&x,&y,&z);
scanf("%d%d%d",&vx,&vy,&vz);
double c = 1.0*x*x+1.0*y*y+1.0*z*z-1.0*r*r;
double b = 2.0*x*vx+2.0*y*vy+2.0*z*vz;
double a = 1.0*vx*vx+1.0*vy*vy+1.0*vz*vz;
double d = b*b - 4 * a * c;
if (d>-EPS && d<0)
{
d = 0;
}
if (d<0)
bt[i] = et[i] = 1E100;
else
{
bt[i] = (-b - sqrt(d))/(2*a) - EPS;
et[i] = (-b + sqrt(d))/(2*a) + EPS;
}
}
sort(bt,bt+n);
sort(et,et+n);
int m;
cin>>m;
int t;
for (int i=0;i<m;i++)
{
cin>>t;
int bc = lower_bound(bt,bt+n,(double)t) - bt;
int ec = lower_bound(et,et+n,(double)t) - et;
cout<<bc-ec<<endl;
}
return 0;
}
I2luY2x1ZGU8aW9zdHJlYW0+CiNpbmNsdWRlPGNtYXRoPgojaW5jbHVkZTxhbGdvcml0aG0+CiNpbmNsdWRlPGNzdGRpbz4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKIApjb25zdCBkb3VibGUgRVBTID0gMUUtNzsKaW50IHgseSx6LHZ4LHZ5LHZ6Owpkb3VibGUgYnRbMTAwMDAxXTsKZG91YmxlIGV0WzEwMDAwMV07CmludCBtYWluKCkKewogICAgaW50IG4scjsKICAgICAgICBjaW4+Pm4+PnI7CiAgICAgICAgZm9yIChpbnQgaT0wO2k8bjtpKyspCiAgICAgICAgewogICAgICAgICAgICAgICAgc2NhbmYoIiVkJWQlZCIsJngsJnksJnopOwogICAgICAgICAgICAgICAgc2NhbmYoIiVkJWQlZCIsJnZ4LCZ2eSwmdnopOwogICAgICAgICAgICAgICAgZG91YmxlIGMgPSAxLjAqeCp4KzEuMCp5KnkrMS4wKnoqei0xLjAqcipyOwogICAgICAgICAgICAgICAgZG91YmxlIGIgPSAyLjAqeCp2eCsyLjAqeSp2eSsyLjAqeip2ejsKICAgICAgICAgICAgICAgIGRvdWJsZSBhID0gMS4wKnZ4KnZ4KzEuMCp2eSp2eSsxLjAqdnoqdno7CiAgICAgICAgICAgICAgICBkb3VibGUgZCA9IGIqYiAtIDQgKiBhICogYzsKICAgICAgICAgICAgICAgIGlmIChkPi1FUFMgJiYgZDwwKQogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICBkID0gMDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGlmIChkPDApCiAgICAgICAgICAgICAgICAgICAgICAgIGJ0W2ldID0gZXRbaV0gPSAxRTEwMDsKICAgICAgICAgICAgICAgIGVsc2UKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgYnRbaV0gPSAoLWIgLSBzcXJ0KGQpKS8oMiphKSAtIEVQUzsKICAgICAgICAgICAgICAgICAgICAgICAgZXRbaV0gPSAoLWIgKyBzcXJ0KGQpKS8oMiphKSArIEVQUzsKICAgICAgICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgc29ydChidCxidCtuKTsKICAgICAgICBzb3J0KGV0LGV0K24pOwogCiAgICAgICAgaW50IG07CiAgICAgICAgY2luPj5tOwogICAgICAgIGludCB0OwogICAgICAgIGZvciAoaW50IGk9MDtpPG07aSsrKQogICAgICAgIHsKICAgICAgICAgICAgICAgIGNpbj4+dDsKICAgICAgICAgICAgICAgIGludCBiYyA9IGxvd2VyX2JvdW5kKGJ0LGJ0K24sKGRvdWJsZSl0KSAtIGJ0OwogICAgICAgICAgICAgICAgaW50IGVjID0gbG93ZXJfYm91bmQoZXQsZXQrbiwoZG91YmxlKXQpIC0gZXQ7CiAgICAgICAgICAgICAgICBjb3V0PDxiYy1lYzw8ZW5kbDsKICAgICAgICB9CiAKICAgICAgICByZXR1cm4gMDsKfQog