#include <iostream>
#include <vector>
#define int long long

using namespace std;

int maxx(int a, int b)
{
	if (a > b) return a;
	return b;
}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t;
	cin >> t;
	while (t--)
	{
		int n, m;
		cin >> n >> m;
		vector<int> x(m);
		for (int i = 0; i < m; ++i) cin >> x[i];
		cout << (n - 1) * x[0] + x[0] * (maxx(0, m - n + 1) % 2) << '\n';
	}
}