#include<bits/stdc++.h>

using namespace std;
#define int long long

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

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie();
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
