#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = long double;

#define all(vec) vec.begin(), vec.end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define int ll

mt19937_64 rnd;

const ll d = 250;

ll INF = 1e9;

int dp[100][2 * d + 1][2 * d + 1];

void solve() {
    ll n, m;
    cin >> n >> m;
    vector<ll> x(m + 1);
    for (int i = 1; i <= m; i++) cin >> x[i];
    dp[0][d][d] = 1;
    for (int lvl = 0; lvl < m; lvl++) {
        for (int i = 0; i <= 2 * d; i++) {
            for (int j = 0; j <= 2 * d; j++) {
                if (dp[lvl][i][j] == 0) continue;
                dp[lvl + 1][x[lvl + 1] + d + d - i][j] = 1;
                dp[lvl + 1][i][x[lvl + 1] + d + d - j] = 1;
            }
        }
    }
    int ans = -INF;
    for (int i = 0; i <= 2 * d; i++) {
        for (int j = 0; j <= 2 * d; j++) {
            if (dp[m][i][j]) {
                ans = max(ans, i + j - 2 * d);
            }
        }
    }
    cout << ans << "\n";
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    ll t = 1;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
