#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

//#pragma GCC Optimize("O3")
//#pragma GCC Optimize("unroll-loops")
//#pragma GCC target("avx,avx2,bmi")

//using namespace __gnu_pbds;
using namespace std;

//template <class T> using ordered_set = tree<T, null_type, less<T> ,rb_tree_tag,tree_order_statistics_node_update>;
//struct h{
//    size_t operator ()(const pair<int,int>& a) const{
//        return ((size_t)a.first << 32) + a.second;
//    }
//};
void solve();

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    cin>>t;
    while (t--) {
        solve();
    }
    return 0;
}

#define int long long
#define endl '\n'
const int INF = 2e18;
const int MAXN = 3e5+1;
const int MOD = 1e9 + 7;

void solve() {
    int n,m;
    cin >> n >> m;
    vector<int> a(m);
    for (int i = 0; i < m; i++) {
        cin >> a[i];
    }
    vector<vector<int>> dp(n + 1, vector<int>(1001, -INF));
    dp[0][500]=0;
    for (int i = 0; i < m; i++) {
        for (int j = -500; j <= 500; j++) {
            dp[i+1][j+500] = max(dp[i+1][j+500], dp[i][j+500] * -1 + a[i]);
            if (j * -1 + a[i] + 500 <= 1000 && j * -1 + a[i] + 500 >=0) {
                dp[i+1][j * -1 + a[i] + 500] = max(dp[i+1][j*-1+a[i]+500], dp[i][j+500]);
            }
        }
    }
    int ans = -INF;
    for (int j = -500; j <= 500; j++) {
        ans = max(ans, j + dp[n][j+500]);
    }
    cout << ans << endl;
}
