#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll INF = 1e18;

int main()
{
    int t;
    cin >> t;
    while(t--)
    {
        int n,m;
        cin >> n >> m;
        int x[m];
        for(int i = 0;i < m;++i)
        {
            cin >> x[i];
        }
        ll dp[m+1][n+1];
        for(int j = 0;j < m;++j)
        {
            for(int np = n;np >= 0;--np)
            {
                if(j == 0)
                {
                    dp[j][np] = (np == 0 ? -x[j] : (np == n ? x[j] : max(x[j],-x[j])));
                }
                else if(np == n)
                {
                    dp[j][np] = x[j] + dp[j-1][np-1];
                }
                else if(np == 0)
                {
                    dp[j][np] = -x[j] + dp[j-1][np+1];
                }
                else
                {
                    dp[j][np] = max(x[j] + dp[j-1][np-1],-x[j] + dp[j-1][np+1]);
                }
                //cout << dp[j][np] << ' ';
            }
            //cout << "\n";
        }
        cout << dp[m-1][n] << "\n";
    }
    return 0;
}
