#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 maxn = 2001;
const ll inf = 1e18;

ll dp[maxn][maxn]; // number of pluses

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 <= n; j++)
        {
            if (i == 0)
            {
                dp[i][j] = 0;
            }
            else
            {
                dp[i][j] = -inf;
            }
        }
    }
    for (ll i = 0; i < m; i++)
    {
        for (ll cnt = 0; cnt <= n; cnt++)
        {
            // add plus
            if (cnt < n)
            {
                dp[i + 1][cnt + 1] = max(dp[i + 1][cnt + 1], dp[i][cnt] + arr[i]);
            }
            // add minus
            if (cnt > 0)
            {
                dp[i + 1][cnt - 1] = max(dp[i + 1][cnt - 1], dp[i][cnt] - arr[i]);
            }
        }
    }
    cout << dp[m][n] << '\n';
}

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