#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
mt19937 rnd(time(NULL));
signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t; cin >> t;
    while(t--){
        int n, m; cin >> n >> m;
        vector<int>x(m); for(int i = 0; i < m; i++) cin >> x[i];
        if(n == 1){
            cout << (m % 2) * x[0] << "\n"; return 0;
        }else{
            cout << min(n, m) * x[0] - (m - min(n, m)) % 2 * x[0] << "\n";
        }
    }
    return 0;
}