#include <bits/stdc++.h>

using namespace std;

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin >> t;
    for (int abab = 0; abab < t; abab++) {
        int n, m;
        cin >> n >> m;
        vector<long long> a(m);
        for (int i = 0; i < m; i++) {
            cin >> a[i];
        }
        reverse(a.begin(), a.end());
        vector<vector<long long>> dp(m + 1, vector<long long>(n + 1, -2e18));
        dp[0][n] = 0;
        for (int i = 1; i <= m; i++) {
            for (int j = 0; j < n; j++) {
                dp[i][j] = max(dp[i][j], dp[i - 1][j + 1] + a[i - 1]);
            }
            for (int j = 1; j <= n; j++) {
                dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] - a[i - 1]);
            }
        }
        long long ans = -2e18;
        for (auto x : dp[m]) ans = max(ans, x);
        cout << ans << '\n';
    }
}
