#include <bits/stdc++.h>
using namespace std;
using ll=long long;
ll gcd_(ll a,ll b){
return b==0? a: gcd_(b,a%b);
}
ll find_min(ll pos,ll n,ll k,vector<ll>&arr){
vector<ll> dp(n+1,-1);
if(pos==n)return 0;
if(dp[pos]!=-1){
return dp[pos];
}
ll min_cost=LONG_LONG_MAX;
if(pos+1<=n){
min_cost=min(min_cost,k+find_min(pos+1,n,k,arr));
}
for(ll j=pos+1; j<=n; j++){
ll cost=arr[pos-1]/gcd_(arr[pos-1],arr[j-1]);
min_cost=min(min_cost,cost+find_min(j,n,k,arr));
}
return dp[pos]=min_cost;
}
void solve(){
ll n,k;
cin>>n>>k;
vector<ll> arr(n);
for(ll i=0; i<n; i++)cin>>arr[i];
ll res=find_min(1,n,k,arr);
cout<<res<<endl;
}
int main(){
int t;
cin>>t;
while(t--){
solve();
}
return 0;
}