#pragma GCC optimize("O3,unroll-loops")
#include<bits/stdc++.h>
#pragma GCC target("avx,avx2,bmi,bmi2")

using namespace std;

#define all(x) (x).begin(),x.end()

#ifdef DBG
#define debug(x) cout << #x << " = " << (x) << endl
#else
#define debug(x) 
#endif

using ll = long long;

const ll INF = 1e18;

mt19937 rnd(42);


inline void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> x(m, 0);

    for (int& i : x) cin >> i;

    cout << min(m - 1 + (n - m + 1) & 1, n) * x[0] << '\n';
} 


int main() {
    int t = 1;
    // #ifdef DBG
    cin >> t;
    // #endif
    for (int i = 0; i < t; ++i) {
        solve();
        #ifdef DBG
        cout << '\n';
        #endif
    }
}