#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define all(x) x.begin(), x.end()
#define ff first
#define ss second

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using ll = long long;
using ld = long double;
using pll = pair<ll, ll>;
using pii = pair<int, int>;

void solve() {
    ll n, m;
    cin >> n >> m;
    vector<ll> x(n);
    for (ll i = 0; i < n; ++i) {
        cin >> x[i];
    }
    ll val = x[0];
    ll ans = min(n, m) * val;
    if (m > n) {
        m -= n;
        m %= 2;
        if (m) {
            ans -= val;
        }
    }
    cout << ans << endl;
}

signed main() {
    ll t;
    cin >> t;
    while (t--) {
        solve();
    }
}
