#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <deque>
#include <iomanip>
using namespace std;
using ll = long long;
void solve() {
	ll n, m;
	cin >> n >> m;
	vector<ll> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	if (m <= n) {
		cout << m * a[0] << endl;
	}
	else {
		if ((m - n) % 2 == 0) {
			cout << m * a[0] << endl;
		}
		else {
			cout << (m - 1) * a[0] << endl;
		}
	}
}
int main()
{
	ll t;
	cin >> t;
	while (t--) {
		solve();
	}
}

