
#include <iostream>
#include <limits>
#include <chrono>
#include <random>
#include <iomanip>
#include <algorithm>
#include <chrono>
#include <random>
#include <math.h>
#include <set>
using namespace std;
#define int long long

void solve() {


	int n, m;
	cin >> n >> m;
	vector <int> vec(m);
	for (int i = 0;i < m;i++)cin >> vec[i];
	int val = vec[0] * min(n, m);
	if (n >= m) {
		cout << val;
		exit(0);
	}
	else {
		if ((n - m) % 2 == 0) {
			cout << val;
		}
		else {
			cout << val - vec[0];
		}
	}
}
signed main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t;
	cin >> t;
	while (t--) {
		solve();
	}
}
