#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fr first
#define sc second
#define all(x) x.begin(), a.end()
void fst(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
}

const int maxn = 2e5;

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


signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    fst();
    int t;cin >> t;
    while(t--){
        solve();
    }

}
