#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
using ll = long long;
using ld = long double;
const ll INF = 1e18;


int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	int t; cin >> t;
	for (int _ = 0; _ < t; ++_) {
		int n, m;
		cin >> n >> m;
		vector<ll> x(m);
		for (int i = 0; i < m; ++i)
			cin >> x[i];
		if (m <= n) {
			cout << x[0] * m << "\n";
		}
		else {
			if ((m - n) % 2 == 0)
				cout << x[0] * n << "\n";
			else
				cout << x[0] * (n - 1) << "\n";
		}
	}

	return 0;
}