#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;

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

int main() {
    int t = 1; cin >> t;
    while (t--) {
        solve();
    }
}
