//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("02")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define int long long
/*int gcd(int a, int b, int &x, int &y){
    //cout << a << " " << b << "\n";
    if (a == 0){
        x = 0y = 1;
        return b;
    }
    int x1, y1;
    int d = gcd(b % a, a, x1, y1);
    x = y1 - b / a * x1;
    y = x1;
    return d;
}*/
const int inf = 1e18 + 7;
void solve(){
    int n, m;
    cin >> n >> m;
    vector<int> x(m + 1);
    for (int i = 1; i <= m; i++){
        cin >> x[i];
    }
    vector<vector<int>> dp(m + 1, vector<int> (n + 1, -inf));
    dp[0][0] = 0;
    for (int  i= 1; i <= m; i++){
        for (int j = 0 ;j <= n; j++){
            if (dp[i - 1][j] == -inf){
                continue;
            }
            if (j + 1 <= n){
                dp[i][j + 1] = max(dp[i][j + 1], dp[i - 1][j] + x[i]);
            }
            if (j - 1 >= 0){
                dp[i][j - 1] = max(dp[i][j - 1], dp[i - 1][j] - x[i]);
            }
        }
    }
    int ans= 0;
    for (int j = 0 ; j <= n; j++){
        ans = max(ans, dp[m][j]);
    }
    cout << ans << "\n";
}
signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t;
    cin >> t;
    while (t--){
        solve();
    }


}
