#include <bits/stdc++.h>

using namespace std;

using ll = long long;

int main() {
    cin.tie(0)->sync_with_stdio(0);

    auto isqrt = [&](ll x) {
        ll s = sqrt(x);
        for (ll y = max(s - 2, 0ll); y <= s + 2; y++) {
            if (y * y > x) return y - 1;
        }
    };

    int t; cin >> t;
    while (t--) {
        vector<array<ll, 3>> a;
        vector<int> times;
        int n, q; cin >> n >> q;
        for (int i = 0; i < n; i++) {
            int tt, x, y; cin >> tt >> x >> y;
            a.push_back({tt, x, y});
        }
        for (int i = 0; i < q; i++) {
            int tt; cin >> tt;
            times.push_back(tt);
        }
        vector<ll> al;
        for (int i = 0; i < a.size(); i++) {
            for (int j = i + 1; j < a.size(); j++) {
                auto [tt1, x1, y1] = a[i];
                auto [tt2, x2, y2] = a[j];
                auto d2 = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
                if (d2 < (tt1 - tt2) * (tt1 - tt2)) {
                    // never meet
                } else if (d2 == (tt1 - tt2) * (tt1 - tt2)) {
                    al.push_back(tt2);
                } else { // meet once when circles meet, then twice forever after
                    // meet after tt2 + (tt2 - tt1) - sqrt(d2)
                    auto d = isqrt(d2);
                    if (d * d == d2 && (d - (tt2 - tt1)) % 2 == 0) {
                        al.push_back(tt2 + (d - (tt2 - tt1)) / 2);
                    } else {
                        al.push_back(tt2 + (d - (tt2 - tt1)) / 2 + 1);
                    }
                    al.push_back(tt2 + (d - (tt2 - tt1)) / 2 + 1);
                }
            }
        }
        sort(al.begin(), al.end());
        for (auto x : times) {
            if (al.size() == 0) {
                cout << 0 << " ";
                continue;
            }
            cout << (upper_bound(al.begin(), al.end(), x) - al.begin()) << " ";
        }
        cout << "\n";
    }
}