#include <bits/stdc++.h>

#define ll long long

using namespace std;

void fast_in_out() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
ll n,i,x[300010],m,j;
const ll inf=1e18;
int main() {
    fast_in_out();
    ll t;
    cin >> t;
    while(t--){
        cin >> n >> m;
        ll dp[m+10][n+10];
        for(i=m;i>=1;i--)cin >> x[i];
        for(i=0;i<=n;i++){
            for(j=0;j<=m;j++)dp[j][i]=-inf;
        }
        dp[0][n]=0;
        for(j=1;j<=m;j++){
            for(i=0;i<=n;i++){
                if(i>0)dp[j][i]=max(dp[j][i],dp[j-1][i-1]-x[j]);
                if(i<n)dp[j][i]=max(dp[j][i],dp[j-1][i+1]+x[j]);
            }
        }
        ll ans=-inf;
        for(i=0;i<=n;i++)ans=max(ans,dp[m][i]);
        cout << ans << '\n';
    }
    return 0;
}
