#include <bits/stdc++.h>

using namespace std;

const long long INF = 1e18;

long long final_ans = 0;

int n, m;
vector<long long> a;
vector<int> used;
vector<int> p;
vector<int> num;

void rec(int i, int last){
    if (i > m){
        /*cout << "new permutation: " << endl;
        for (int j = 1; j <= m; ++j)
            cout << p[j] << " ";
        cout << endl;
        for (int j = 1; j <= m; ++j)
            cout << num[j] << " ";
        cout << endl;*/

        vector<int> counted(m + 1);
        long long ans = 0;
        for (int j = m; j >= 1; --j){
            if (counted[j]) continue;
            counted[j] = 1;
            int y = j;
            long long temp = 0;
            while (y > 0){
                counted[y] = 1;
                temp += ((num[j] - num[y]) % 2 ? -a[y] : a[y]);
                y = p[y];
            }
            ans += temp;
            //cout << "j = " << j << ":  " << temp << endl;
        }
        //cout << "ans = " << ans << endl << endl;
        final_ans = max(final_ans, ans);
        return;
    }
    if (last > 0){
        p[i] = 0;
        num[i] = 1;
        rec(i + 1, last - 1);
    }
    for (int j = 1; j < i; ++j){
        if (!used[j]){
            used[j] = 1;
            p[i] = j;
            num[i] = num[j] + 1;
            rec(i + 1, last);
            used[j] = 0;
        }
    }
}

int main()
{
    int t; cin >> t;
    for (int ti = 0; ti < t; ++ti){
        cin >> n >> m;
        a.resize(m + 1);
        for (int i = 1; i <= m; ++i)
            cin >> a[i];

        used.resize(m + 1);
        p.resize(m + 1);
        num.resize(m + 1);

        final_ans = -INF;
        rec(1, n);

        cout << final_ans << endl;

        /*long long ans = -INF;
        for (int i = 0; i < (1 << m); ++i){
            bitset<20> mask(i);
            int cnt = 0;
            long long temp = 0;
            bool ok = true;
            for (int j = 0; j < m; ++j){
                if (mask[j]){
                    ++cnt;
                    temp += a[j];
                }
                else{
                    --cnt;
                    temp -= a[j];
                }
                if (cnt < 0 || cnt > n){
                    ok = false;
                    break;
                }
            }
            if (ok){
                if (temp > ans){
                    cout << "new " << mask << endl;
                }
                ans = max(ans, temp);
            }
        }

        cout << ans << endl;*/
    }

    return 0;
}
