#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <random>
#include <climits>
#include <time.h>
#include <cmath>
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx2")

using namespace std;
using ll = long long;
using ld = long double;
ll inf = 4e18;

random_device rd;
mt19937 gen(rd());
uniform_int_distribution <> distr(0, INT_MAX);

ll binpow(ll x, ll d, ll mod) {
	if (d == 0)
		return 1;
	if (d == 1)
		return x;
	ll cur = binpow(x, d >> 1, mod) * binpow(x, d >> 1, mod) % mod;
	if (d & 1)
		cur = cur * x % mod;
	return cur;
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t;
	cin >> t;
	while (t--) {
		ll 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';
			continue;
		}
		ll extra = n - m;
		if (extra & 1)
			cout << x[0] * (n - 1) << '\n';
		else
			cout << x[0] * n << '\n';
	}
}