#define _GLIBCXX_DEBUG
#define _GLIBCXX_DEBUG_PEDANTIC

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define OPTIMIZETHISSHIT ios::sync_with_stdio(false); cin.tie(nullptr);
#define int long long
#define pb push_back

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

mt19937_64 rng(0);

int rand(int l, int r) {
    return uniform_int_distribution<int>(l, r)(rng);
}

void solve() {
    int n;
    cin >> n;
    int m;
    cin >> m;
    vector<int> a(m);
    for (int i = 0; i < m; i++) cin >> a[i];
    int ans = -INT_MAX;
    for (int mask = 0; mask < (1 << m); mask++) {
        int cnt_1 = 0;
        for (int j = 0; j < m; j++) {
            if (mask & (1 << j)) cnt_1++;
        }
        if (cnt_1 < cnt_0) continue;
        int cnt_0 = m - cnt_1;
        vector<vector<int>> stacks(n);
        vector<bool> check(n, true);
        bool govno = false;
        for (int j = 0; j < m; j++) {
            bool s = mask & (1 << j);
            bool valid = false;
            for (int i = 0; i < n; i++) {
                if (check[i] == s) {
                    stacks[i].pb(a[j]);
                    valid = true;
                    check[i] = !check[i];
                    break;
                }
            }
            if (valid) continue;
            else govno = true;
        }
        if (govno) continue;
        cout << cnt_1 << ' ' << cnt_0 << endl;
        int sm = 0;
        for (int i = 0; i < n; i++) {
            if (stacks[i].size() % 2 == 0) {
                for (int j = 0; j < stacks[i].size(); j++) {
                    if (j % 2 == 0) {
                        sm -= stacks[i][j];
                    } else {
                        sm += stacks[i][j];
                    }
                }
            } else {
                for (int j = 0; j < stacks[i].size(); j++) {
                    if (j % 2 == 1) {
                        sm -= stacks[i][j];
                    } else {
                        sm += stacks[i][j];
                    }
                }
            }
        }
        ans = max(ans, sm);
    }
    cout << ans << endl;
}

signed main() {
    OPTIMIZETHISSHIT

    int t;
    cin >> t;
    while (t--) solve();
}

