#include <bits/stdc++.h>
using namespace std;
#define int long long

vector<vector<int>> dp;

int f(int i, int cm, vector<int>& x, int n){
    if (dp[i][cm] != -1e15) return dp[i][cm];
    if (i == 0) return (dp[i][cm] = 0);
    int cp = n - cm;
    if (cm >= 1){
        dp[i][cm] = max(dp[i][cm], f(i-1, cm-1, x, n) - x[i-1]);
    }
    if (cp >= 1){
        dp[i][cm] = max(dp[i][cm], f(i-1, cm+1, x, n) + x[i-1]);
    }
    return dp[i][cm];
}

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int t; cin >> t;
    while (t--){
        int n, m; cin >> n >> m;
        vector<int> x(m);
        for (int i = 0; i < m; ++i) cin >> x[i];
        dp.resize(m+1);
        for (int i = 0; i <= m; ++i) dp[i].resize(n+1);
        for (int i = 0; i <= m; ++i) for (int j = 0; j <= n; ++j) dp[i][j] = -1e15;
        cout << f(m, 0, x, n) << "\n";
    }
}
