#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <map>
#include <unordered_map>
#include <unordered_set>
//#include <cmath>
//#include <numeric>

//#pragma GCC optimize("O3, unroll-loops")
//#pragma GCC target("avx2, avx, lzcnt, popcnt, bmi, bmi2")

using namespace std;

#define int long long

void solve(){
    int n, m;
    cin >> n >> m;
    vector<int> A(m);
    for (int i = 0; i < m; i++){
        cin >> A[i];
    }
    if (m < n){
        cout << A[0] * m << '\n';
    }else if ((m - n) % 2 == 0){
        cout << A[0] * n << '\n';
    }else{
        cout << A[0] * (n - 1) << '\n';
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin >> t;
    while(t--){
        solve();
    }
}
