#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int t; cin >> t;
    while (t--) {
        int n, m; cin >> n >> m;
        vector<int> x(m+1);
        for (int i = 1; i <= m; ++i) cin >> x[i];
        vector<vector<int64_t>> dp(m+1, vector<int64_t>(n+1, 0));
        for (int i = 1; i <= m; ++i) {
            dp[i][0] = dp[i-1][1]+x[i];
            dp[i][n] = dp[i-1][n-1]-x[i];
            for (int j = 1; j < n; ++j) {
                dp[i][j] = max(dp[i-1][j+1]+x[i], dp[i-1][j-1]-x[i]);
                dp[i][j] = dp[i-1][j+1]+x[i];
            }
        }
        cout << dp[m][0] << '\n';
    }

    return 0;
}
