#include <bits/stdc++.h>

using namespace std;

void solve()
{
    int n, m;
    cin>>n>>m;
    vector<int> x(m);
    for(int i=0; i<m; ++i){
        cin>>x[i];
    }
    reverse(x.begin(), x.end());


    vector<vector<long long>> dp(m+1, vector<long long>(n+1, -1e18));
    dp[0][0]=0;

    for(int i=1; i<=m; ++i){
        for(int j=0; j<n; ++j){
            dp[i][j]=dp[i-1][j+1]-x[i-1];
        }
        for(int j=1; j<=n; ++j){
            dp[i][j]=max(dp[i][j], dp[i-1][j-1]+x[i-1]);
        }
    }

    long long ans=-1e18;

    for(int i=0; i<=n; ++i){
        ans=max(ans, dp[m][i]);
    }
    cout<<ans<<endl;

    /*for(int i=0; i<=m; ++i){
        for(int j=0; j<=n; ++j){
            cout<<dp[i][j]<<" ";
        }cout<<endl;
    }*/
}



int main()
{
    int t;
    cin>>t;
    while(t--){
        solve();
    }
    return 0;
}
