#include<bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx,avx2,bmi,bmi2,sse,sse2,sse3,sse4")
#define int long long
using namespace std;
void gogo() {
    int n, m;
    cin >> n >> m;
    int a[m];
    for (int i = 0; i < m; i++) {
        cin >> a[i];
    }
    reverse(a, a + m);
    array<pair<int, int>, 100>ar;
    int sz = 1;
    ar[0] = {0, 0};
    for (int i = 0; i < m; i++) {
        array<pair<int, int>, 100>nv_ar;
        int pt = 0;
        for (int j = 0; j < sz; j++) {
            if (pt < 100 && ar[j].second > 0) {
                nv_ar[pt++] = {ar[j].first - a[i], ar[j].second - 1};
            }
            if (pt < 100 && ar[j].second < n) {
                nv_ar[pt++] = {ar[j].first + a[i], ar[j].second + 1};
            }
        }
        sort(nv_ar.begin(), nv_ar.begin() + pt);
        reverse(nv_ar.begin(), nv_ar.begin() + pt);
        sz = pt;
        for (int i = 0; i < sz; i++) {
            ar[i] = nv_ar[i];
        }
    }
    cout << ar[0].first << endl;
}
main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    cin >> t;
    while (t--) {
        gogo();
    }
}

//25 62 100 86
//max 273