#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll inf = 1e9;
ll solve()
{
    ll n, m;
    cin >> n >> m;
    vector<ll> v(m);
    for (auto& x : v) cin >> x;
    reverse(v.begin(), v.end());
    vector<vector<ll>> dp(m + 1, vector<ll> (n + 1, -inf));
    dp[0][0] = 0;
    for (ll i = 1; i <= m; i++)
        for (ll s = 0; s < n + 1; s++)
        {
            if (s > 0) dp[i][s] = max(dp[i][s], dp[i - 1][s - 1] + v[i - 1]);
            if (s < n) dp[i][s] = max(dp[i][s], dp[i - 1][s + 1] - v[i - 1]);
        }
    return *max_element(dp[m].begin(), dp[m].end());
}
int main()
{
    ll t;
    cin >> t;
    while (t--)
        cout << solve() << '\n';
}
