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

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

#define vi vector<int>
#define vvi vector<vi>
#define vll vector<ll>
#define vc vector<char>
#define vvc vector<vc>
#define pii pair<int, int>
#define ll long long

#define f(i, n) for(int i=0;i<n;i++)
#define f1(i, n) for(int i=1;i<n;i++)
#define fr(i, n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(), v.end()

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<>, rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update> ti;

int n, m;
vi a;
vi xs;

ll tr(int i)
{
    if (i == m)
        return accumulate(all(a), 0ll);
    int cur = xs[i];
    ll res = -9e18;
    f(j, n)
    {
        a[j] = cur - a[j];
        res = max(res, tr(i+1));
        a[j] = cur - a[j];
    }
    return res;
}

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

    int t;
    cin >> t;
    f(q, t)
    {
        cin >> n >> m;
        a = vi(n);
        xs = vi(m);
        f(i, m)
            cin >> xs[i];
        ll res = tr(0);
        cout << res << '\n';
    }

    return 0;
}