#include<bits/stdc++.h>
using namespace std;
// #Placement
vector<int> conv(string x);
int solve(vector<int> a, int k);
int num(string x, int l, int r);
int main(){
char ws;
int t;
cin>>t;
ws=cin.get();
while(t--){
string x;
getline(cin,x);
int k;
cin>>k;
vector<int> a=conv(x);
cout<<solve(a,k)<<endl;
}
return 0;
}
vector<int> conv(string x){
vector<int> a;
int l=0,r=0;
while(r<x.size()){
while(r<x.size()-1){
if(x[r]==' '){
r--;
break;
}
r++;
}
cout<<l<<" "<<r<<endl;
int n=num(x,l,r);
a.push_back(n);
l=r+2;
r=l;
}
return a;
}
int num(string x, int l, int r){
int ans=0;
int i=r;
int place=1;
while(i>=l){
ans+=place*(x[i]-'0');
place*=10;
i--;
}
return ans;
}
int solve(vector<int> a, int k){
int cap=1;
while(1){
int trips=0;
for(int i=0;i<a.size();i++){
trips+=(a[i]/cap);
if(a[i]%cap!=0){
trips++;
}
}
if(trips<=k){
return cap;
}
cap++;
}
}