#define _CRT_SECURE_NO_WARNINGS
#ifndef _DEBUG
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#endif
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <set>
#include <unordered_set>
#include <map>
#include <deque>
#include <queue>
#include <unordered_map>
#include <iomanip>
using namespace std;
using ll = long long;
using ld = long double;
using str = string;
using pll = pair<ll, ll>;
auto sd = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 rnd(sd);
void sol1() {
	ll n, m;
	cin >> n >> m;
	vector<ll> a(n);
	vector<ll> x(m);
	for (int i = 0; i < m; i++) {
		cin >> x[i];
	}
	if (m <= n) {
		if (x[0] < 0) {
			if (m % 2 == 0) {
				cout << 0 << endl;
			}
			else {
				cout << x[0] << endl;
			}
		}
		else {
			cout << x[0] * m << endl;
		}
	} 
	else {
		if (x[0] < 0) {
			if (m % 2 == 0) {
				cout << 0 << endl;
			}
			else cout << x[0] << endl;
		}
		else {
			m -= n;
			if (m % 2 == 0) {
				cout << x[0] * n << endl;
			}
			else {
				cout << x[0] * (n - 1) << endl;
			}
		}
	}

	/*
	vector<map<pll, ll>> xi(m + 1);
	xi[0][{0, 0}] = 1;
	for (int j = 0; j < m; j++) {
		for (auto& e : xi[j]) {
			ll ai = e.first.first;
			ll aj = e.first.second;
			xi[j + 1][{x[j] - ai, aj}] = 1;
			xi[j + 1][{ai, x[j] - aj}] = 1;
		}
		xi[j].clear();
	}
	ll mx = -1e18;
	for (auto& u : xi[m]) {
		mx = max(mx, u.first.first + u.first.second);
	}
	cout << mx<<endl;*/

}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
#ifdef _DEBUG
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif
	ll t1 = 1;
	cin >> t1;
	for (int o_ = 0; o_ < t1; o_++) sol1();
}

