#include <bits/stdc++.h>

using namespace std;
#define int long long

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

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t = 1;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
