#include <bits/stdc++.h>
using namespace std;
mt19937 rnd(time(0));
void solve(){
    int n, m;
    cin >> n >> m;
    vector <int> x(m);
    for (int i = 0; i < n; i++){
        cin >> x[i];
    }
    if (n >= m){
        cout << m * x[0] << '\n';
    }
    else{
        if ((m - n) % 2 == 0){
            cout << n * x[0] << '\n';
        }
        else{
            cout << (n - 1) * x[0] << '\n';
        }
    }
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t;
    cin >> t;
    while (t--){
        solve();
    }
}

