#include <bits/stdc++.h>

using namespace std;

void solve()
{
    int n, m;
    cin>>n>>m;
    vector<long long> x(m);
    for(int i=0; i<m; ++i){
        cin>>x[i];
    }
    if(n>=m){
        cout<<x[0]*m<<endl;
    }else{
        int k=m-n;
        k=k/2+k%2;
        cout<<(m-k-k)*x[0]<<endl;
    }
}



int main()
{
    int t;
    cin>>t;
    while(t--){
        solve();
    }
    return 0;
}
