#include <bits/stdc++.h>

using namespace std;

void solve();

//#pragma GCC optimize("O3","Ofast","fastmath","unroll-loops")
//#pragma GCC target("avx2","sse4.2","bmi","lzcnt","popcnt")
int main() {
#ifdef LOCAL
    freopen("input.txt","r",stdin);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

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

#define int long long
#define endl '\n'
const int N=3e5+10,INF=2e18,MOD=1e9+7;

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