#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
using ll = long long;
const ll inf = 1e18 + 52;

void solve() {
    int n, k;
    cin >> k >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    if (n > k)
        cout << a[0] * (k - (abs(n - k) % 2));
    else
        cout << a[0] * n << endl;
}

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t;
    cin >> t;
    while (t--) {
        solve();
    }

}