#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <stack>
#include <deque>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#define int long long

using namespace std;

void solve() {
	int n, m;
	cin >> n >> m;
	vector <int> arr(n, 0), brr(m);
	for (int i = 0; i < m; i++) {
		cin >> brr[i];
	}
	if (m <= n) {
		cout << brr[0] * m << '\n';
		return;
	}
	else {
		int ans = brr[0] * m;
		if ((m - n) % 2 == 1) {
			ans -= brr[0];
		}
		cout << ans << '\n';
	}
}

signed main() {
	int t;
	cin >> t;
	while (t--) {
		solve();
	}
}
