#include
using namespace std;
int main() {
unsigned int test_case;
unsigned int no_enm,damage;
unsigned int health[200];
unsigned int max = 0;
unsigned int multi_time;
unsigned int single_time;
cin>>test_case;
for(int i = 0;i < test_case;i++){
cin>>no_enm>>damage;
for(int i = 0;i < no_enm;i++){
cin>>health[i];
}
//multitarget
for(int j = 0;j < no_enm;j++){
if(health[j] > max){
max = health[j];
}
}
multi_time = max;
//single
single_time = 0;
for(int z = 0;z < no_enm;z++){
while(health[z] != 0){
single_time = health[z]/damage + single_time;
if(health[z] >= damage){
health[z] = health[z]%damage;
}
else if(health[z] < damage){
health[z] = health[z]/damage;
single_time = single_time + 1;
}
}
}
if(multi_time > single_time){
cout<<single_time<<endl;
}
else{
cout<<multi_time<<endl;
}
}
return 0;
}