#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);

    int t;
    cin >> t;

    while (t--) {
        int n, m;
        cin >> n >> m;

        long long sum = 0;
        vector<int> a(n, 0), b(m);
        for (int i = 0; i < m; ++i) {
            cin >> b[i];
            sum += b[i];
        }

        if (m <= n) {
            cout << sum << "\n";
        } else {
            cout << (n - ((m - n) & 1)) * b[0] << "\n";
        }
    }

    return 0;
}
