#include <bits/stdc++.h>

using ll = long long;

using namespace std;

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

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll t = 1;
    cin >> t;
    for (ll i = 0; i < t; i++) {
        solve();
    }
    return 0;
}
