//#pragma GCC optimize("Ofast")
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bits/stdc++.h>
#define int long long
#define ld long double
#define speed ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
//#pragma GCC target("avx2")
const int INF = 1e12, maxn = 3e5 + 100;
void resh() {
    int n, m, sum = 0;
    cin >> n >> m;
    vector<int> bb(m);
    for (auto& i : bb) {
        cin >> i;
        sum += i;
    }

    if (m <= n) {
        cout << sum << '\n';
        return;
    }

    sum = 0;
    for (int i = 0; i < n; i++) {
        sum += bb[0];
    }

    if ((m - n) % 2 == 1) {
        cout << sum - bb[0] << '\n';
        return;
    }
    cout << sum << '\n';

}
signed main() {
    int t;
    cin >> t;
    for (int i = 0; i < t; i++) {
        resh();
    }
}