#include <bits/stdc++.h>

using namespace std;

using ll = long long;

const ll infll = 1e18;

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
    cin >> t;
    for (int i = 0; i < t; i++) solve();
}
