#include <bits/stdc++.h>

using namespace std;
using ll = long long;
//#define int ll
const ll inf = 1e16;

const int mxv = 1.2e3;
const int hehehaha = 1'00'000;

mt19937 rnd(228130012);

int rand(int l, int r) {
    return l + rnd() % (r - l + 1);
}

void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> x(m);
    for (int i = 0; i < m; i++) {
        cin >> x[i];
    }
    ll ans = -inf;
    for (int _ = 0; _ < hehehaha; _++) {
        vector<int> a(n);
        for (int i = 0; i < m; i++) {
            int op = rand(0, n - 1);
            a[op] = x[i] - a[op];
        }
        ans = max(ans, accumulate(a.begin(), a.end(), 0ll));
    }
    cout << ans << "\n";
}

signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    cin >> t;
    while (t--)
        solve();
}