#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <random>
#include <map>
#include <queue>

using namespace std;
using ll = long long;

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(0);

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

	return 0;
}
