#include <bits/stdc++.h>

#define int long long
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using namespace std;

void solve_case() {
    int n, m; cin >> n >> m;
    vector<int> x(m);
    for (int i = 0; i < m; i++) {
        cin >> x[i];
    }
    if (m <= n) {
        cout << x[0] * m << '\n';
        return;
    }
    cout << ((m - n) % 2 ? x[0] * n - x[0] : x[0] * n) << '\n';
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    cin >> t;
    while (t--) {
        solve_case();
    }
}