#include <bits/stdc++.h>

using namespace std;
#define int long long
using pii = pair<int, int>;
using ll = long long;

int inf = 1e18;

void solve(){
    int n, m;
    cin >> n >> m;
    vector <int> a(m);
    for (int i = 0; i < m; i++){
        cin >> a[i];
    }

    vector <vector <int>> dp(m + 1, vector <int> (n + 1, -inf));


    if (n == 1){
        int ans = 0;
        for (int i = 0; i < m; i++){
            ans = a[i] - ans;
        }
        cout << ans << '\n';
        return;
    }
    else {

        dp[1][n - 1] = a[0];

        for (int i = 2; i <= m; i++) {
            for (int j = 0; j <= n; j++) {
                if (j == 0){
                    dp[i][j + 1] = max(dp[i][j + 1], dp[i - 1][j] - a[i - 1]);
                }
                else if (j == n){
                    dp[i][j - 1] = max(dp[i][j - 1], dp[i - 1][j] + a[i - 1]);
                }
                else {
                    dp[i][j + 1] = max(dp[i][j + 1], dp[i - 1][j] - a[i - 1]);
                    dp[i][j - 1] = max(dp[i][j - 1], dp[i - 1][j] + a[i - 1]);
                }
            }
        }

        int ans = 0;
        for (int i = 0; i < m; i++){
            ans = max(ans, dp[n][i]);
        }
        cout << ans << '\n';
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int tt = 1;
    cin >> tt;
    while (tt--) {
        solve();
    }
    return 0;
}
