#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <bitset>
#include <string>
#include <vector>
#include <cmath>
#include <deque>
#include <queue>
#include <set>
#include <map>

using namespace std;

#define for0(i, n) for (ll i = 0; i < n; ++i)
#define for1(i, n) for (ll i = 1; i <= n; ++i)
#define fora(i, v) for (auto i : v)
#define ft first
#define sd second
#define pk push_back
#define pok pop_back
#define ret return
#define con continue
#define sz(v) v.size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using ll = long long;
using pll = pair <ll, ll>;
using vll = vector <ll>;
using vpll = vector <pll>;
using vvll = vector <vll>;
using pi = pair <int, int>;
using vi = vector <int>;
using vpi = vector <pi>;
using vvi = vector <vector <int>>;

const ll N = 3e5;

ll t, n, m;
ll a[N + 1], x[N + 1];

int main() {
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(false);
	cin >> t;
	while (t--) {
		cin >> n >> m;
		for1(i, m)
			cin >> x[i];
		if (n >= m)
			cout << x[1] * m << "\n";
		else if ((m - n) % 2 == 0)
			cout << x[1] * n << "\n";
		else
			cout << x[1] * (n - 1) << "\n";
	}
	ret 0;
}