#include <bits/stdc++.h>

using namespace std;

void solve() {
    int n, m; cin >> n >> m;
    vector<int> a(m);
    for (int i = 0; i < m; i++) {
        cin >> a[i];
    }
    int x = min(n, m);
    x += max((m - n) / 2, 0);
    cout << x * a[0] << '\n';
}

int main() {
    //ios::sync_with_stdio(false);
    //cin.tie(nullptr);
    int t; cin>> t;
    while (t--) solve();
}
