#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <random>
#include <deque>
#include <stack>
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;
using ld = long double;
using str = string;
#define int ll

//mt19937 rnd(288);

const int INF = 1e9 + 239;
const int EPS = 1e-9;

void fastw() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
}

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

signed main() {
	fastw();
	int tt = 1;
	cin >> tt;
	while (tt--) {
		solve();
		cout << '\n';
	}
}