#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <random>
#include <map>
#include <queue>

using namespace std;
using ll = long long;

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(0);

	int t;
	cin >> t;
	while (t--) {
		int n, m;
		cin >> n >> m;
		vector<ll> x(m);
		for (int i = 0; i < m; ++i) {
			cin >> x[i];
		}
		ll a = *min_element(x.begin(), x.end());
		ll b = *max_element(x.begin(), x.end());
		ll c1 = 0, c2 = n;
		ll rs = 0;
		for (int i = m - 1; i >= 0; --i) {
			if (x[i] == a) {
				if (c2 == 0) {
					++c2;
					rs -= a;
				}
				else {
					++c1;
					--c2;
					rs += a;
				}
			}
			else {
				if (c2 == 0) {
					if (c1 == 0) {
						--c1;
						rs += b;
						rs -= 2 * a;
						++c2;
					}
					else {
						++c2;
						rs -= b;
					}
				}
				else {
					--c2;
					rs += b;
				}
			}
		}
		cout << rs << '\n';
	}
	return 0;
}
