#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;

    vector<vector<vector<bool>>> dp(2, vector<vector<bool>> (5001, vector<bool> (5001)));
    dp[0][500][500] = 1;
    for(int i = 0; i < m; ++i){
        int k = x[i];
        for(int a = -500; a <= 500; ++a){
            for(int b = -500; b <= 500; ++b){
                dp[1][a+500][b+500] = 0;
                if(k-a >= -500 && k-a <= 500 && dp[0][k-a+500][b+500]){
                    dp[1][a+500][b+500] = 1;
                }
                if(k-b >= -500 && k-b <= 500 && dp[0][a+500][k-b+500]){
                    dp[1][a+500][b+500] = 1;
                }
            }
        }
        swap(dp[1], dp[0]);
    }
    for(int a = -500; a <= 500; ++a){
        for(int b = -500; b <= 500; ++b){
            if(dp[0][a+500][b+500]){
                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;
}
