#include <bits/stdc++.h>

using namespace std;

#define int long long

int INF = 1e17;


void sovel() {
    int n, m;
    cin >> n >> m;
    vector<int> x(m);
    for (auto& to:x) cin >> to;
    if (m <= n) {
        cout << x[0] * m << "\n";
        return;
    }
    cout << x[0] * (n - 1) + ((m - n) % 2 == 0) * x[0] << "\n";
}

signed main() {
    int t = 1;
    cin >> t;
    while (t--) {
        sovel();
    }
}
