#include <bits/stdc++.h>

using namespace std;

#define int int64_t
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define ld long double

const int maxn = 2e5;
const int inf = 4e18;
const int LOG = 30;
const int N = 2e3;
const ld eps = 1e-12;

inline void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> a(m);
    for(int &i : a) cin >> i;

    int sm = a[0] * n;
    if(n <= m && (m - n) % 2 == 1) {
        cout << sm - a[0] << '\n';
    } else {
        cout << sm << '\n';
    }
    return;
}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);


#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int tt = 1;
    cin >> tt;

    while(tt--) {
        solve();
    }
    return 0;
}
