#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <set>
#include <map>

#pragma GCC optimize("O3")

#define out(x) std::cout << x << ' ';
#define oute(x) std::cout << x << '\n';
#define enter std::cout << '\n';
#define debout(x) std::cout << #x << x << '\n';
#define debvout(x) std::cout << #x << " : "; for (auto i: x) std::cout << x << ' '; std::cout << '\n';
#define all(x) x.begin(), x.end()
using ll = long long;

void s1nmeee() {
    ll n, q;
    std::cin >> n >> q;
    std::vector<ll> a(n), x(q);
    for (ll& i : x) std::cin >> i;
    ll ans;
    if (n <= q) {
        ans = x[0] * n;
        if ((q - n) % 2) ans -= a[0];
    }
    else {
        ans = x[0] * q;
    }
    out(ans)
}

signed main() {
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false);
    ll TT = 1;
    std::cin >> TT;
    while (TT--) {
        s1nmeee();
        std::cout << '\n';
    }
}