#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <ctime>
#include <climits>
#include <iomanip>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <string>
#include <queue>
#include <random>

#define int long long

#pragma GCC optimize("03,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")

using ll = long long;
using ld = long double;
using namespace std;

const ll INF = 1e18;


void solve() {
    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<vector<int>>> dp(m, vector<vector<int>>(m + 1, vector<int>(m + 1, -INF)));
    dp[0][0][1] = a[0];
    dp[0][1][0] = a[0];
    for (int i = 1; i < m; i++){
        for (int x = 0; x <= m; x++){
            for (int y = 0; y <= m; y++){
                if (x + y != i + 1) continue;
                if (x == 0){
                    dp[i][x][y] = dp[i - 1][x][y - 1];
                    if (y % 2 == 0){
                        dp[i][x][y] -= a[i];
                    } else {
                        dp[i][x][y] += a[i];
                    }
                } else if (y == 0){
                    dp[i][x][y] = dp[i - 1][x - 1][y];
                    if (x % 2 == 0){
                        dp[i][x][y] -= a[i];
                    } else {
                        dp[i][x][y] += a[i];
                    }
                } else {
                    if (x % 2 == 0){
                        dp[i][x][y] = dp[i - 1][x - 1][y] - a[i];
                    } else {
                        dp[i][x][y] = dp[i - 1][x - 1][y]  + a[i];
                    }
                    if (y % 2 == 0){
                        dp[i][x][y] = max(dp[i][x][y], dp[i - 1][x][y - 1] - a[i]);
                    } else {
                        dp[i][x][y] = max(dp[i][x][y], dp[i - 1][x][y - 1] + a[i]);
                    }
                }
            }
        }
    }
    int mx = -INF;
    for (int x = 0; x <= m; x++){
        for (int y = 0; y <= m; y++){
            mx = max(mx, dp[m - 1][x][y]);
        }
    }
    cout << mx << "\n";
}


signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin >> t;
    while (t--){
        solve();
    }
    return 0;
}