// #include <string>
// #pragma GCC optimize("O3,unroll-loops")
// #pragma GCC target("avx2")

#include <bits/stdc++.h>

using namespace std;

using ld = long double;
using ll = long long;

//#define int long long

const int MAXM = 50;
short dp[MAXM][2 * 10 * MAXM + 1][2 * 10 * MAXM + 1];

void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> x(m);
    for (int i = 0; i < m; ++i) {
        cin >> x[i];
    }
    dp[0][x[0] + 500][0 + 500] = 1;
    dp[0][0 + 500][x[0] + 500] = 1;
    for (int i = 1; i < m; ++i) {   
        for (int a = -500; a <= 500; ++a) {
            for (int b = -500; b <= 500; ++b) {
                if (a == -7 && b == 0)
                    int adsad = 1;
                int pra = x[i] - a;
                int prb = x[i] - b;
                dp[i][a + 500][b + 500] = 0;
                if (abs(pra) <= 500) {
                    dp[i][a + 500][b + 500] |= dp[i - 1][pra + 500][b + 500];
                }
                if (abs(prb) <= 500) {
                    dp[i][a + 500][b + 500] |= dp[i - 1][a + 500][prb + 500];
                }
                // if (dp[i][a + 500][b + 500]) {
                //     cout << a << ' ' << b << '\n';
                // }
            }
        }
    }
    int mx = -1e9;
    for (int a = -500; a <= 500; ++a) {
        for (int b = -500; b <= 500; ++b) {
            if (dp[m - 1][a + 500][b + 500]) {
                //cout << a << ' ' << b << '\n';
                mx = max(mx, a + b);
            }
        }
    }

    cout << mx;
}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int tt = 1;
    cin >> tt;
    for (int i = 0; i < tt; ++i) {
        solve();
        cout << '\n';
    }
}