#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using pp = pair<ll, ll>;
using ld = long double;

template <typename T>
istream &operator>>(istream &s, vector<T> &a)
{
    for (T &el : a)
    {
        s >> el;
    }
    return s;
}

template <typename T>
ostream &operator<<(ostream &s, vector<T> &a)
{
    for (T el : a)
    {
        s << el << ' ';
    }
    s << '\n';
    return s;
}

const ll maxm = 401, maxn = 2;
const ll inf = 1e18;

ll dp[maxm][1 << maxn];

void solve()
{
    ll n, m;
    cin >> n >> m;
    vector<ll> arr(m);
    cin >> arr;
    for (ll i = 0; i <= m; i++)
    {
        for (ll j = 0; j < (1 << n); j++)
        {
            if (i == 0)
            {
                dp[i][j] = 0;
            }
            else
            {
                dp[i][j] = -inf;
            }
        }
    }
    dp[0][0] = 0;
    for (ll i = 0; i < m; i++)
    {
        for (ll mask = 0; mask < (1 << n); mask++)
        {
            for (ll choice = 0; choice < n; choice++)
            {
                ll sign;
                if ((mask >> choice) & 1)
                {
                    sign = -1;
                }
                else
                {
                    sign = 1;
                }
                dp[i + 1][mask ^ (1 << choice)] = max(dp[i + 1][mask ^ (1 << choice)], dp[i][mask] + arr[i] * sign);
            }
        }
    }
    cout << dp[m][(1 << n) - 1] << '\n';
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll t;
    cin >> t;
    while (t--)
    {
        solve();
    }
}