// #pragma GCC optimize("Ofast,fast-math,unroll-loops,no-stack-protector,inline")
#include <bits/stdc++.h>

using namespace std;

#define int long long
#define map unordered_map
const int M = 100;

signed main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    freopen("input.txt", "r", stdin);
    int t;
    cin >> t;
    for (int q = 0; q < t; q++) {
        int n, m;
        cin >> n >> m;
        vector<int> arr(m);
        for (int i = 0; i < m; i++) {
            cin >> arr[i];
        }
        vector<pair<int, int>> dp;
        dp.push_back({0, 0});
        for (int i = m - 1; i >= 0; i--) {
            int cur = arr[i];
            vector<pair<int, int>> cur1;
            for (auto [j, num] : dp) {
                if (j < n) {
                    cur1.push_back({num + cur, j + 1});
                }
                if (j > 0) {
                    cur1.push_back({num - cur, j - 1});
                }
            }
            map<int, bool> used;
            sort(cur1.rbegin(), cur1.rend());
            int num = 0;
            vector<pair<int, int>> dp1;
            for (int j = 0; j < cur1.size() && num < M; j++) {
                if (!used[cur1[j].second]) {
                    used[cur1[j].second] = 1;
                    dp1.push_back({cur1[j].second, cur1[j].first});
                    num++;
                }
            }
            dp = dp1;
        }
        int mx = -1e18;
        for (auto [j, num] : dp) {
            mx = max(mx, num);
        }
        cout << mx << endl;
    }
}