#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pii = pair<int, int>;
constexpr char nl = '\n';

void solve() {
    int n, m;
    cin >> n >> m;
    vi a(m);
    for (int i = 0; i < m; ++i) {
        cin >> a[i];
    }
//    sort(a.begin(), a.end());
    ll ans = 0;

    n = min(n, m);
    if ((m-n) % 2)
        --n;
    cout << 1ll * a[0] * n << nl;
//    for (int i = 0; i < (m - n) / 2; ++i) {
//        ans -= a[i];
//    }
//    for (int i = (m - n) / 2; i < m; ++i) {
//        ans += a[i];
//    }
//    cout << ans << nl;
}

signed main() {
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);

    int t;
    cin >> t;
    while (t--)
        solve();
}
