#pragma GCC optimize("O3,unroll-loops")
#include<bits/stdc++.h>
#pragma GCC target("avx,avx2,bmi,bmi2")

using namespace std;

#define all(x) (x).begin(),x.end()

#ifdef DBG
#define debug(x) cout << #x << " = " << (x) << endl
#else
#define debug(x) 
#endif

using ll = long long;

const ll INF = 1e18;

mt19937 rnd(42);


inline void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> x(m, 0);

    for (int& i : x) cin >> i;

    reverse(all(x));

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

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

    cout << mx << '\n';
} 


int main() {
    int t = 1;
    // #ifdef DBG
    cin >> t;
    // #endif
    for (int i = 0; i < t; ++i) {
        solve();
        #ifdef DBG
        cout << '\n';
        #endif
    }
}