#include <bits/stdc++.h>
#define ll long long
using namespace std;
void solve() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    ll n,m;
    cin >> n >> m;
    vector<ll> a(m);
    for (int i = 0;i < m;i++) {
        cin >> a[i];
    }
    if (n%2==m%2) {
        cout << n*a[0];
    }
    else {
        cout << (n-1)*a[0];
    }
    /*reverse(a.begin(),a.end());
    vector<vector<ll>> dp(m+1,vector<ll> (n+1,-1e18));
    dp[0][0] = 0;
    for (int i = 1;i < m+1;i++) {
        for (int j = 0;j <= n;j++) {
            if (j!=0) {
                dp[i][j] = max(dp[i][j],dp[i-1][j-1]+a[i-1]);
            }
            if (j!=n) {
                dp[i][j] = max(dp[i][j],dp[i-1][j+1]-a[i-1]);
            }
            //cout << dp[i][j] << ' ';
        }
        //cout << '\n';
    }
    ll ma = -1e18;
    for (int j = 0;j <= n;j++) {
        ma = max(ma,dp[m][j]);
    }
    cout << ma << '\n';*/
}
int main()
{
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
