#include <bits/stdc++.h>

using namespace std;
#define int long long

signed main() {
    cin.tie(0);
    cout.tie(0);
    int t;
    cin >> t;
    while (t--) {
        int n, m;
        cin >> m >> n;
        vector<int> x(n);
        for (int i = 0; i < n; i++) {
            cin >> x[i];
        }
        int ans = x[0] * (min(n, m) - (max((n - m), 0LL) % 2));
        cout << ans << "\n";
    }
    return 0;
}