/*#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx2")
#pragma GCC optimize("Ofast")*/

#include <iostream>
#include <math.h>
#include <iostream>
#include <string>
#include <fstream>
#include <set>
#include <vector>
#include <algorithm>
#include <random>

using namespace std;
using ll = long long;
using ld = long double;
const ll MAXN = 1e17+6;
const ll MOD = 1e9 + 7;
void volve(){
    ll n,m,x;
    cin >> n >> m;
    vector<ll> arr;
    for (int i = 0;i<m;i++){
        cin >> x;
        arr.push_back(x);
    }
    vector<pair<ll,ll>> dp(m+1,{0,0});
    vector<pair<ll,ll>> pred(m+1,{-1,-1});
    ll cnt,ind;
    for (int i = 0;i<m;i++){
        cnt = -MAXN;
        ind = 0;
        for (int j = 0;j<=i;j++){
            if (arr[i] - dp[j].second > cnt){
                cnt = arr[i] - dp[j].second;
                ind = j;
            }
        }
        pred[i+1].first = ind;
        dp[i+1].first = cnt;
        cnt = MAXN;
        ind = 0;
        for (int j = 0;j<=i;j++){
            if (arr[i] - dp[j].first < cnt){
                cnt = arr[i] - dp[j].first;
                ind = j;
            }
        }
        pred[i+1].second = ind;
        dp[i+1].second = cnt;
    }
    vector<bool> index(m+1,false);
    ll res = -MAXN;
    ind = 0;
    for (int i = 0;i<=m;i++){
        if (res < dp[i].first){
            res = dp[i].first;
            ind = i;
        }
    }
    bool flag = false;
    while (true){
        if (ind == -1){
            break;
        }
        index[ind] = true;
        if (flag){
            ind = pred[ind].second;
            flag = false;
        }
        else{
            ind = pred[ind].first;
            flag = true;
        }
    }
    ll res2 = 0;
    for (int i = 1;i<=m;i++){
        if (!index[i]){
            res2 = arr[i-1] - res2;
        }
    }
    cout << res + res2 << "\n";
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll t;
    cin >> t;
    while (t--){
        volve();
    }
}
