#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

#define len(x) (int)x.size()
#define all(x) x.begoin(), x.end()
const ll INF = 1e18;
const int INFi = 1e9;

void solve() {
    int n, m;
    cin >> n >> m;

    vector<int> x(m);
    for (auto &i: x) {
        cin >> i;
    }

    if (n >= m) {
        cout << 1ll * m * x[0] << '\n';
    } else {
        cout << 1ll * n * x[0] - x[0] * ((m - n) & 1) << '\n';
    }


}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt","w", stdout);
#endif

    int t = 1;
    cin >> t;
    while(t--) {
        solve();
    }

    return 0;
}