#include <bits/stdc++.h>

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx")

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template<class T> using oset = tree<T, null_type, less_equal<>, rb_tree_tag, tree_order_statistics_node_update>;

#define int long long
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

void solve(){
    int n, m;
    cin >> n >> m;
    vector<int> x(m);
    for(int i = 0; i < m; ++i){
        cin >> x[i];
    }
    int ans = -1e18;
    int c = 1000;
    vector<vector<vector<bool>>> dp(2, vector<vector<bool>> (2*c+1, vector<bool> (2*c+1)));
    dp[0][c][c] = 1;
    for(int i = 0; i < m; ++i){
        int k = x[i];
        for(int a = -c; a <= c; ++a){
            for(int b = -c; b <= c; ++b){
                dp[1][a+c][b+c] = 0;
                if(k-a >= -c && k-a <= c && dp[0][k-a+c][b+c]){
                    dp[1][a+c][b+c] = 1;
                }
                if(k-b >= -c && k-b <= c && dp[0][a+c][k-b+c]){
                    dp[1][a+c][b+c] = 1;
                }
            }
        }
        swap(dp[1], dp[0]);
    }
    for(int a = -c; a <= c; ++a){
        for(int b = -c; b <= c; ++b){
            if(dp[0][a+c][b+c]){
                ans = max(ans, a+b);
            }
        }
    }
    cout << ans;
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int tt = 1;
    cin >> tt;
    while(tt--){
        solve();
        cout << '\n';
    }
    return 0;
}
