#include <iostream>
#include <vector>
#include <algorithm>

#define int long long

using namespace std;

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int inf = 1e9;
    int t;
    cin >> t;
    for (int _ = 0; _ < t; ++_) {
        int n, m;
        cin >> n >> m;
        vector<int> a(m);
        for (int i = 0; i < m; ++i) {
            cin >> a[i];
        }
        reverse(a.begin(), a.end());
        vector<vector<int>> dp(m);
        for (int i = 0; i < m; ++i) {
            for (int j = 0; j < n + 1; ++j) {
                dp[i].push_back(-1e18);
            }
        }
        dp[0][1] = a[0];
        for (int i = 1; i < m; ++i) {
            for (int j = 0; j <= n; ++j) {
                if (j == 0) {
                    dp[i][j] = dp[i - 1][j + 1] - a[i];
                }
                else if (j == n) {
                    dp[i][j] = dp[i - 1][j - 1] + a[i];
                }
                else {
                    dp[i][j] = max(dp[i - 1][j - 1] + a[i], dp[i - 1][j + 1] - a[i]);
                }
            }
        }
        int ans = -1e18;
        for (auto i: dp[m - 1]) {
            ans = max(ans, i);
        }
        cout << ans << endl;
    }
}
