#include <bits/stdc++.h>

using namespace std;
using ll = long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;


int main(int, char**) {
    cout << setprecision(15) << fixed;
#ifdef DEBUGMB
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
#endif

    ll t;
    cin >> t;
    while (t--) {
        ll n, m;
        cin >> n >> m;
        vector<ll> x(m);
        for (auto& el : x) {
            cin >> el;
        }
        if (m <= n) {
            cout << m * x[0];
            return 0;
        }
        cout << n * x[0] - ((m - n) % 2 == 1 ? x[0] : 0) << "\n";
    }



    return 0;
}
