#include <bits/stdc++.h>

using namespace std;
#define int int64_t
const int INF = 1e18;
void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> x(m + 1);
    for (int i = 1; i <= m; i++) {
        cin >> x[i];
    }
    int sz = 80 * m;
    bool dp[m + 1][sz + 1][sz + 1];
    for (int i = 0; i <= m; i++) {
        for (int s1 = 0; s1 <= sz; s1++) {
            for (int s2 = 0; s2 <= sz; s2++) {
                dp[i][s1][s2] = false;
            }
        }
    }
    dp[0][sz / 2][sz / 2] = true;
    for (int pr = 1; pr <= m; pr++) {
        for (int s1 = 0; s1 <= sz; s1++) {
            for (int s2 = 0; s2 <= sz; s2++) {
                if (dp[pr - 1][s1][s2] == false) {
                    continue;
                }
                s1 -= (sz / 2);
                s2 -= (sz / 2);
                dp[pr][x[pr] - s1 + (sz / 2)][s2 + (sz / 2)] = true;
                dp[pr][(sz / 2) + s1][x[pr] - s2 + (sz / 2)] = true;
            }
        }
    }
    int ans = -INF;
    for (int s1 = 0; s1 <= sz; s1++) {
        for (int s2 = 0; s2 <= sz; s2++) {
            if (dp[m][s1][s2] == false) {
                continue;
            }
            ans = max(ans, s1 - (sz / 2) + s2 - (sz / 2));
        }
    }
    cout << ans << '\n';
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
}


