//author: лелутик :3
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <bitset>
#include <time.h>
#include <cmath>
#include <cassert>
#include <random>
#include <queue>
#include <deque>
using namespace std;
#define int long long
#define line cout << "\n"
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back
#define ppb pop_back
#define sz(a) (int) a.size()
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pii pair<int, int>


void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> a(m);
    for (int i = 0; i < m; i++) {
        cin >> a[i];
    }
    int ans = -1e18;
    for (int i = 0; i < (1 << m); i++) {
        vector<bool> types;
        queue<int> st;
        int sm = 0;
        for (int j = 0; j < m; j++) {
            if (i & (1 << j)) {
                sm += a[j];
                types.pb(true);
                st.push(j);
            } else {
                sm -= a[j];
                types.pb(false);
            }
        }
        int cnt_of_zero = n;
        int cnt_of_plus = 0;
        bool f = true;
        for (int j = 0; j < m; j++) {
            if (types[j] == true) {
                if (sz(st) && st.front() == j) {
                    if (cnt_of_zero) {
                        cnt_of_zero--;
                        cnt_of_plus++;
                    } else {
                        f = false;
                    }
                    st.pop();
                }
            } else {
                if (sz(st)) {
                    if (cnt_of_plus == 0) {
                        if (cnt_of_zero == 0) {
                            f = false;
                        }
                        cnt_of_zero--;
                        cnt_of_plus++;
                    }
                    st.pop();
                } else {
                    f = false;
                }
            }
        }
        if (f) {
            ans = max(ans, sm);
        }
    }
    cout << ans; line;
}

signed main() {
    fast;


#ifdef LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif


    int t = 1;
    cin >> t;
    while (t--) {
        solve();
    }
}