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

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

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

    int t;
    cin >> t;

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

        long long sum = 0;

        vector<int> a(n, 0), b(m);
        for (int i = 0; i < m; ++i) {
            cin >> b[i];
        }

        queue<pair<int, vector<int>>> q;

        set<pair<int, vector<int>>> visited;
        visited.insert({0, a});
        q.push({0, a});

        long long ans = 0;
        while (!q.empty()) {
            int it = q.front().first;
            vector<int> c = q.front().second;
            q.pop();

            long long sum = 0;
            if (it == m - 1) {
                for (int i = 0; i < n; ++i) {
                    sum += c[i];
                }
            }

            for (int i = 0; i < n; ++i) {
                sum -= c[i];
                c[i] = b[it] - c[i];
                sum += c[i];

                if (!visited.count({it + 1, c})) {
                    visited.insert({it + 1, c});
                    if (it == m - 1) {
                        ans = max(ans, sum);
                    } else {
                        q.push({it + 1, c});
                    }
                }
                
                sum -= c[i];
                c[i] = b[it] - c[i];
                sum += c[i];
            }
        }

        cout << ans << "\n";
    }

    return 0;
}
