#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

template<typename T>
bool assign_max(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

template<typename T>
bool assign_min(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll t;
	cin >> t;
	for (ll i = 0; i < t; i++) {
		solve();
	}
}
