#include <bits/stdc++.h>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;

#define int long long
const int INF = 1e9;

void solve1();

// typedef tree<int,null_type,less<>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie();
    cout.tie();
    int qwerty = 1;
    cin >> qwerty;
    while(qwerty--){
        solve1();
    }
}

void solve1(){
    int n, m;
    cin >> n >> m;
    vector<int> a(m);
    for(int i = 0; i < m; i++){
        cin >> a[i];
    }
    reverse(a.begin(), a.end());
    vector<vector<int>> dp(m, vector<int> (n + 1, -INF));
    dp[0][n - 1] = a[0];
    for(int i = 1; i < m; i++){
        // if +
        for(int j = 0; j < n; j++){
            dp[i][j] = max(dp[i][j], dp[i - 1][j + 1] + a[i]);
        }
        // if -
        for(int j = 1; j <= n; j++){
            dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] - a[i]);
        }
    }
    int mx = -INF;
    for(int i = 0; i <= n; i++){
        mx = max(mx, dp[m - 1][i]);
    }
    cout << mx << '\n';
}
