#include <bits/stdc++.h>

using namespace std;
using ll = long long;
//#define int ll
const int inf = 1e9;

void solve() {
    int n, m;
    cin >> n >> m;
    multiset<int> tm;
    int mxv = 1e3;
    vector<vector<bool>> dp(mxv * 2 + 1, vector<bool>(mxv * 2 + 1));
    vector<int> x(m);
    dp[mxv][mxv] = 1;
    for (int i = 0; i < m; i++) {
        cin >> x[i];
        vector<vector<bool>> cp(mxv * 2 + 1, vector<bool>(mxv * 2 + 1));
        for (int j = 0; j < dp.size(); j++) {
            for (int z = 0; z < dp[0].size(); z++) {
                if (dp[j][z]) {
                    int a = j - mxv;
                    int b = z - mxv;
                    cp[x[i] - a + mxv][b + mxv] = 1;
                    cp[a + mxv][x[i] - b + mxv] = 1;
                }
            }
        }
        dp = cp;
    }
    int ans = -inf;
    for (int j = 0; j < dp.size(); j++) {
        for (int z = 0; z < dp[0].size(); z++) {
            if (dp[j][z]) {
                ans = max(ans, j + z - mxv * 2);
            }
        }
    }
    cout << ans;
}

signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    cin >> t;
    while (t--)
        solve();
}