#include<iostream>
#include<algorithm>
using namespace std;
long long a[9000010];
bool cmp(int a,int b){
return a>b;
}
int main(){
long long t,n,m,b[3010];
cin>>t;
while(t--){
cin>>n>>m;
for(int i=0;i<n;i++)
cin>>b[i];
long long len = 0;
sort(b,b+n,cmp);
if(m>=n0.5(n-1))n=n;
else n=min(n,m)/2+7;
}