//author: лелутик :3
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <bitset>
#include <time.h>
#include <cmath>
#include <cassert>
#include <random>
#include <queue>
#include <deque>
using namespace std;
#define int long long
#define line cout << "\n"
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back
#define ppb pop_back
#define sz(a) (int) a.size()
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pii pair<int, int>


void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> a(m);
    for (int i = 0; i < m; i++) {
        cin >> a[i];
    }
    vector<vector<vector<int>>> dp(m + 1, vector<vector<int>>(n + 1, vector<int>(n + 1, -1e18)));
    dp[0][n][0] = 0;
    for (int i = 0; i < m; i++) {
        // plus
        for (int j = 1; j <= n; j++) {
            for (int k = 0; k <= n; k++) {
                dp[i + 1][j - 1][k] = max(dp[i + 1][j - 1][k], dp[i][j][k] + a[i]);
            }
        }
        for (int j = 0; j < n; j++) {
            for (int k = 1; k <= n; k++) {
                dp[i + 1][j][k - 1] = max(dp[i + 1][j][k - 1], dp[i][j][k] + a[i]);
            }
        }
        // minus
        for (int j = 0; j < n; j++) {
            for (int k = 0; k < n; k++) {
                dp[i + 1][j][k + 1] = max(dp[i + 1][j][k + 1], dp[i][j][k] - a[i]);
            }
        }
        for (int j = 1; j <= n; j++) {
            for (int k = 0; k < n; k++) {
                dp[i + 1][j - 1][k + 1] = max(dp[i + 1][j - 1][k + 1], dp[i][j][k] - a[i]);
            }
        }
    }
    int ans = -1e18;
    for (int i = 0; i <= n; i++) {
        ans = max(ans, dp[m][i][0]);
    }
    cout << ans; line;
}

signed main() {
    fast;


#ifdef LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif


    int t = 1;
    cin >> t;
    while (t--) {
        solve();
    }
}