#pragma gcc optimize 02
#include<bits/stdc++.h>
#define FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
typedef long ll;
ll n,m,R;
double a, b, c, l, r, delta;
int cnt[10000009];
void Init ( ll x, ll y, ll z, ll vx, ll vy, ll vz )
{
a = vx * vx + vy * vy + vz * vz;
b = 2 * x * vx + 2 * y * vy + 2 * z * vz;
c = x * x + y * y + z * z - R * R;
delta = b * b - 4 * a * c;
l = ( -b - sqrt ( delta ) ) / ( 2 * a );
r = ( -b + sqrt ( delta ) ) / ( 2 * a );
if(r < 0) return;
if(l < 0) l = 0;
if(long(l) != l) l = long(l) + 1;
r = long(r);
for(int i=l; i<=r; ++i) ++cnt[i];
}
void Input()
{
cin >> n >> R;
while(n--){
ll x, y, z, vx, vy, vz;
cin >> x >> y >> z >> vx >> vy >> vz;
Init ( x, y, z, vx, vy, vz );
}
}
void Sol(){
cin >> m;
while(m--){
ll x;
cin >> x;
cout << cnt[x] << "\n";
}
}
int main()
{
FastIO;
Input();
Sol();
}
I3ByYWdtYSBnY2Mgb3B0aW1pemUgMDIKI2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KI2RlZmluZSBGYXN0SU8gaW9zX2Jhc2U6OnN5bmNfd2l0aF9zdGRpbygwKSxjaW4udGllKDApLGNvdXQudGllKDApOwp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKdHlwZWRlZiBsb25nIGxsOwpsbCBuLG0sUjsKZG91YmxlIGEsIGIsIGMsIGwsIHIsIGRlbHRhOwppbnQgY250WzEwMDAwMDA5XTsKCnZvaWQgSW5pdCAoIGxsIHgsIGxsIHksIGxsIHosIGxsIHZ4LCBsbCB2eSwgbGwgdnogKQp7CiAgICBhID0gdnggKiB2eCArIHZ5ICogdnkgKyB2eiAqIHZ6OwogICAgYiA9IDIgKiB4ICogdnggKyAyICogeSAqIHZ5ICsgMiAqIHogKiB2ejsKICAgIGMgPSB4ICogeCArIHkgKiB5ICsgeiAqIHogLSBSICogUjsKICAgIGRlbHRhID0gYiAqIGIgLSA0ICogYSAqIGM7CiAgICBsID0gKCAtYiAtIHNxcnQgKCBkZWx0YSApICkgLyAoIDIgKiBhICk7CiAgICByID0gKCAtYiArIHNxcnQgKCBkZWx0YSApICkgLyAoIDIgKiBhICk7CiAgICBpZihyIDwgMCkgcmV0dXJuOwogICAgaWYobCA8IDApIGwgPSAwOwogICAgaWYobG9uZyhsKSAhPSBsKSBsID0gbG9uZyhsKSArIDE7CiAgICByID0gbG9uZyhyKTsKICAgIGZvcihpbnQgaT1sOyBpPD1yOyArK2kpICsrY250W2ldOwp9Cgp2b2lkIElucHV0KCkKewogICAgY2luID4+IG4gPj4gUjsKICAgIHdoaWxlKG4tLSl7CiAgICAgICAgbGwgeCwgeSwgeiwgdngsIHZ5LCB2ejsKICAgICAgICBjaW4gPj4geCA+PiB5ID4+IHogPj4gdnggPj4gdnkgPj4gdno7CiAgICAgICAgSW5pdCAoIHgsIHksIHosIHZ4LCB2eSwgdnogKTsKICAgIH0KfQoKdm9pZCBTb2woKXsKICAgIGNpbiA+PiBtOwogICAgd2hpbGUobS0tKXsKICAgICAgICBsbCB4OwogICAgICAgIGNpbiA+PiB4OwogICAgICAgIGNvdXQgPDwgY250W3hdIDw8ICJcbiI7CiAgICB9Cn0KCmludCBtYWluKCkKewogICAgRmFzdElPOwogICAgSW5wdXQoKTsKICAgIFNvbCgpOwp9