#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int MOD = 1e9 + 7;
void solve(){
int n, m;
cin >> n >> m;
vector<int> a(n);
vector<int> b(m);
for(int i = 0; i < n; i++){
cin >> a[i];
}
for(int i = 0; i < m; i++){
cin >> b[i];
}
int r = a[0];
sort(a.begin(), a.end());
sort(b.begin(), b.end());
vector<int> s;
int cnt = 0;
for(int i = 0; i < m; i++){
if(b[i] <= r)cnt++;
else if(b[i] > a[n - 1])cnt++;
else {
auto x = a.end() - lower_bound(a.begin(), a.end(), b[i]);
s.push_back(x + 1);
}
}
sort(s.begin(), s.end());
int p = s.size();
for(int i = 1; i <= m; i++){
int tot = (m / i) * i;
if(tot <= cnt){
cout << m / i << " ";
continue;
}
int gone_con = cnt / i;
ll sum = 0;
ll idx = (p - 1) - (m % i);
while(idx >= 0){
sum += s[idx];
idx -= i;
}
cout << sum + gone_con << " ";
}
cout << "\n";
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
cin >> t;
for(int i = 1; i <= t; i++){
solve();
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNkZWZpbmUgbGwgbG9uZyBsb25nCgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY29uc3QgaW50IE1PRCA9IDFlOSArIDc7Cgp2b2lkIHNvbHZlKCl7CglpbnQgbiwgbTsKCWNpbiA+PiBuID4+IG07CgkKCXZlY3RvcjxpbnQ+IGEobik7Cgl2ZWN0b3I8aW50PiBiKG0pOwoJCglmb3IoaW50IGkgPSAwOyBpIDwgbjsgaSsrKXsKCQljaW4gPj4gYVtpXTsKCX0KCQoJZm9yKGludCBpID0gMDsgaSA8IG07IGkrKyl7CgkJY2luID4+IGJbaV07Cgl9CglpbnQgciA9IGFbMF07Cglzb3J0KGEuYmVnaW4oKSwgYS5lbmQoKSk7CgkKCXNvcnQoYi5iZWdpbigpLCBiLmVuZCgpKTsKCXZlY3RvcjxpbnQ+IHM7CglpbnQgY250ID0g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