#include <bits/stdc++.h>

using namespace std;

using ll = long long;

ll solve(ll n,ll m,vector<ll> b){
    ll mx = 1<<m;
    ll ans = LONG_LONG_MIN;
    for (ll l=0;l<mx;l++){
        vector<ll> vec(2,0);
        for (ll i=0;i<m;i++){
            vec[(l>>i)&1] = b[i] - vec[(l>>i)&1];
        }
        ans = max(ans,vec[0]+vec[1]);
    }
    return ans;
}

int main() {
    int T;
    cin >> T;
    while (T--){
        int n,m;
        cin >> n >> m;
        set<ll> st;
        vector<ll> a(m);
        for (int i=0;i<m;i++){
            cin >> a[i];
            st.insert(a[i]);
        }
        if (st.size() == 1){
            ll x = a[0];
            if (m<=n){
                cout << x*m << endl;
            }else{
                cout << x*n - ((m-n)%2)*x << endl;
            }
        }else{
            cout << solve(n,m,a) << '\n';
        }        
    }
}
