#include <iostream>
#include <vector>
#include <algorithm>

#define int long long

using namespace std;



signed main() {
    int t;
    cin >> t;
    for (int _ = 0; _ < t; ++_) {
        int n, m;
        cin >> n >> m;
        vector<int> a(m);
        for (int i = 0; i < m; ++i) {
            cin >> a[i];
        }
        if (m <= n) {
            cout << a[0] * m << endl;
            exit(0);
        }
        if ((m - n) % 2 == 0) {
            cout << a[0] * n << endl;
        }
        else {
            cout << a[0] * n - a[0] << endl;
        }
    }
}
