#include <bits/stdc++.h>
using namespace std;
#define int long long
const long long INF = 1e18, MOD = 1e9 + 7;

void solve();

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin >> t;
    while (t--){
        int n, m;
        cin >> n >> m;
        vector <int> a(m);
        for (int i = 0; i < m; i++){
            cin >> a[i];
        }
        if (n >= m){
            cout << a[0] * m << "\n";
        }
        else{
            m -= n;
            if (m % 2 == 0){
                cout << a[0] * n << "\n";
            }
            else{
                cout << a[0] * (n - 1) << "\n";
            }
        }
    }
}
