#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int t;
    cin >> t;

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

        vector<ll> x(m);
        for (int i = 0; i < m; i++) {
            cin >> x[i];
        }

        if (m <= n) {
            cout << x[0] * m << '\n';
            continue;
        }

        if (n % 2 != m % 2) {
            cout << x[0] * m - x[0];
        } else {
            cout << x[0] * m << '\n';
        }
    }

    return 0;
}
