#include <iostream>
#include <vector>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#define int long long
#define ld long double

using namespace std;

void solve() {
	int n, m;
	cin >> n >> m;
	vector<int> xs(m);
	for (int i = 0; i < m; i++) cin >> xs[i];
	if (m <= n) {
		cout << xs[0] * m << '\n';
	}
	else {
		cout << xs[0] * n - (((m - n) % 2) * xs[0]) << '\n';
	}
}
signed main() {
	int tt = 1; cin >> tt;
	while (tt--)
		solve();
}
/*
7 1
1
2
3
1
5
6
0 1 3 5
2 4 6
7
*/
