#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef __int128 lll;
const ll inf = 2e18, mod = 1e9 + 7;

#define all(a) a.begin(),a.end()
#define F first
#define S second

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    ifstream in("C:\\work\\untitled\\input.txt");

    ll test;cin>>test;
    while(test--){
        ll m,n;cin>>m>>n;
        vector<ll>x(n);
        for(auto &i:x)
            cin>>i;
        cout<<x[0]*m-x[0]*((n-m)%2)<<'\n';
        continue;
        reverse(all(x));
        vector<vector<ll>>dp(n+1,vector<ll>(m+1,-inf));
        dp[0][0]=0;
        for(ll i=1;i<=n;i++){
            ll v=x[i-1];
            for(ll j=0;j<=m;j++){
                if(j&&dp[i-1][j-1]!=-inf)
                    dp[i][j]=max(dp[i][j],dp[i-1][j-1]+v);
                if(j+1<=m&&dp[i-1][j+1]!=-inf)
                    dp[i][j]=max(dp[i][j],dp[i-1][j+1]-v);
            }
        }
        ll ans=-inf;
        for(ll i=0;i<=m;i++)
            ans=max(ans,dp[n][i]);
        cout<<ans<<'\n';
    }
}
