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

#define int long long
#define db long double
#define MX LLONG_MAX
#define MN LLONG_MIN
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a / gcd(a, b) * b)

using namespace std;
using namespace __gnu_pbds;

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

db start;

db get_time() {
    return (clock() - start) / CLOCKS_PER_SEC;
}

int ans;
void solve(int ind, int sum, vector<int> a, const vector<int>& b, const int n, const int m) {
    if (ind == m) {
        //ans = max(ans, sum);
        int cur = 0;
        for (auto x: a) cur += x;
        ans = max(ans, cur);
        return;
    }

    for (int i = 0; i < n; i++) {
        int last = a[i];

        int cur = sum;
        cur -= a[i];
        a[i] = b[ind] - a[i];
        cur += a[i];
        solve(ind + 1, cur, a, b, n, m);

        a[i] = last;
    }
}

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

    start = clock();

    int t;
    cin >> t;

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

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

        ans = 0;
        vector<int> a(n, 0);
        solve(0, 0, a, b, n, m);

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

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

#define int long long
#define db long double
#define MX LLONG_MAX
#define MN LLONG_MIN
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a / gcd(a, b) * b)

using namespace std;
using namespace __gnu_pbds;

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

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

    int n, k;
    cin >> n >> k;

    vector<int> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }

    vector<vector<int>> dp(n + 1, vector<int>(k + 1, 0));
    for (int i = 1; i <= n; i++) {
        dp[i][1] = v[i - 1] + i;
    }

    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= k; j++) {
            for (int u = i - 1; u >= 1; u--) {
                dp[i][j] = max(dp[i][j], dp[u][j - 1] + v[i - 1] + (i - u));
            }
        }
    }

    int ans = 0;
    for (int i = 0; i <= n; i++) {
        ans = max(ans, dp[i][k]);
    }

    cout << ans;
}
*/
