#include <bits/stdc++.h>

using namespace std;

int main() {
    int t;
    cin >> t;
    while (t != 0) {
    int n, m;
    cin >> n >> m;
    vector<int> a(m);
    for (int i = 0; i < m; i++) {
        cin >> a[i];
    }
    long long ans = min(n, m) * a[0];
    int cnt = m - min(n, m) + 1;
    ans -= a[0];
    if (cnt % 2 != 0) {
        ans += a[0];
    }
    cout << ans << "\n";
    t--;
    }
}



