#include <bits/stdc++.h>

using namespace std;

#ifndef lisie_bimbi
#define endl '\n'
#endif

using ll = long long;

const ll inf = 1'000'000'000'000'000'000;

const int N = 1100;

random_device rd;

mt19937 rnd(rd());

int n;

ll get(deque<ll> a){
    vector<ll> dp(n + 1, -inf), dp1;
    dp[0] = 0;
    for(auto x : a){
        dp1.clear();
        dp1.resize(n + 1, -inf);
        for(int i = 0; i <= n; i++){
            if(i - 1 >= 0){
                if(dp[i - 1] != -inf){
                    dp1[i] = max(dp1[i], dp[i - 1] - x);
                }
            }
            if(i + 1 <= n){
                if(dp[i + 1] != -inf){
                    dp1[i] = max(dp1[i], dp[i + 1] + x);
                }
            }
        }
        swap(dp, dp1);
    }
    return dp[0];
}

void solve(){
    int m;
    cin >> n >> m;
    deque<ll> a(m);
    for(int i = 0; i < m; i++){
        cin >> a[i];
    }
    ll ans = -inf;
    for(int i = 0; i <= n; i++){
        ans = max(ans, get(a));
        a.push_front(0);
    }
    cout << ans << endl;
}

signed main(){
#ifdef lisie_bimbi
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    cin.tie(nullptr)->sync_with_stdio(false);
#endif            
    int t = 1;
    cin >> t;
    while(t--){
        solve();
    }
}