#include <iostream>
#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

#define int long long
#define st first
#define nd second

/**
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
**/

#pragma GCC optimize("Ofast, unroll-loops")
#pragma GCC target("avx")

int x[300'300] = {};
int dp[3'000'000] = {};

#define INF (998244353LL * 998244353LL * 4LL)

void solve()
{
    int n, m;
    cin >> m >> n;
    for (int i = 0; i < n; ++i)
    {
        cin >> x[n - 1 - i];
    }
    for (int i = 0; i <= m + n + 2; ++i)
    {
        dp[i] = -INF;
    }
    dp[0 + m] = 0;
    for (int i = 1; i <= n; ++i)
    {
        for (int j = -1; j <= m; ++j)
        {
            dp[i + j] += x[i - 1];
        }
        for (int j = 1; j <= m; ++j)
        {
            dp[i + j] = max(dp[i + j], dp[i + j - 2] - 2 * x[i - 1]);
        }
            /// dp[i][j] = max(j != 0 ? dp[i - 1][j - 1] - x[i - 1] : -INF,
            ///                j != m ? dp[i - 1][j + 1] + x[i - 1] : -INF);
    }
    int ans = -INF;
    for (int i = 0; i <= m; ++i)
    {
        ans = max(ans, dp[n + i]);
    }
    cout << ans << '\n';
}

signed main()
{
    int t;
    cin >> t;
    for (int i = 0; i < t; ++i)
    {
        solve();
    }
    return 0;
}
