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

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

#pragma GCC target("avx2")

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);

    int t;
    cin >> t;

    while (t--) {
        int n, m;
        cin >> n >> m;

        vector<long long> a(n, 0), b(m);
        for (int i = 0; i < m; ++i) {
            cin >> b[i];
        }
        
        vector<long long> dp_mx(1 << m);
        for (int mask = 1; mask < (1 << m); ++mask) {
            long long sum = 0;
            for (int i = 0; i < m; ++i) {
                if (mask >> i & 1) {
                    sum = b[i] - sum;
                }
            }

            dp_mx[mask] = sum;
        }

        
        vector<vector<long long>> dp(1 << m, vector<long long>(n + 1, -1e18));
        dp[0][0] = 0;

        for (int k = 1; k <= n; ++k) {
            for (int mask = 1; mask < (1 << m); ++mask) {
                for (int sub = mask; sub; sub = (sub - 1) & mask) {
                    dp[mask][k] = max(dp[mask][k], dp[mask ^ sub][k - 1] + dp_mx[sub]);
                }
            }
        }

        cout << *max_element(dp[(1 << m) - 1].begin(), dp[(1 << m) - 1].end()) << "\n";
    }

    return 0;
}
