#include<bits/stdc++.h>
#define int long long
using namespace std;
void gogo() {
    int n, m;
    cin >> n >> m;
    int a[m + 1];
    for (int i = 1; i <= m; i++) {
        cin >> a[i];
    }
    reverse(a + 1, a + m + 1);
    int dp[m + 1][n + 1] = {};
    for (int i = 0; i <= m; i++) {
        for (int j = 0; j <= n; j++) {
            dp[i][j] = -LLONG_MAX / 2;
        }
    }
    dp[0][0] = 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]);
        }
        for (int j = 1; j <= n; j++) {
            dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + a[i]);
        }
    }
    int ans = -LLONG_MAX / 2;
    for (int j = 0; j <= n; j++) {
        ans = max(ans, dp[m][j]);
    }
    cout << ans << endl;
}
main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    cin >> t;
    while (t--) {
        gogo();
    }
}
