//#pragma GCC optimize("O3");
//#pragma GCC target("avx, avx2")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#define ALL(X) (X.begin()), (X.end())
#define sz(X) (int)(X.size())

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned int ui;

#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

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

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
   	int t;
   	cin >> t;
   	while (t--) {
   		solve();
   	} 
    return 0;
}
