#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using ll = long long;
using ld = long double;
#define all(array) array.begin(), array.end()
constexpr long long INF =  (long long)2e18 + 1;
constexpr ll inf = 1e9 + 1;
const ll mod = 1e9 + 7;



void solve(){
    ll n, m;
    cin >>  n >> m;
    vector<ll> v(m);
    for(int i = 0 ; i <  m; ++i){
        cin >> v[i];
    }
    ll aa = 0;
    ll bb = 0;
    ll d1 = 0;
    ll d2 = 0;
    ll mm = 0;
    for(int i = 0 ; i < m - 5; ++i){
        d1 = abs(aa - (v[i] - aa));
        d2 = abs(bb - (v[i] - bb));
        mm++;
        if(d1 > d2){
            aa = v[i] - aa;
        }
        else{
            bb = v[i] - bb;
        }
    }

    ll ans = -INF;
    for(int mask = 0; mask < (1 << (m-mm)); ++mask)
    {
        vector<int> q( m);
        ll temp = mask;
        ll ind = 0;
        while(temp){
            if(temp & 1){
                q[ind] = 1;
            }
            ind ++;
            temp = temp >> 1;
        }
        ll a = aa;
        ll b=  bb;
        for(ll i = 0 ; i < m - mm; ++i){
            if(q[i] == 0){
                a = v[i+mm] - a;
            }
            else{
                b = v[i+mm] - b;
            }
        }
        ans = max(ans, a + b);
    }
    cout << ans;
}

signed main(){
    fast;;;
    long long tc = 1;
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    //cin >> tc;
#endif
    cin >> tc;
    while(tc--){
        solve();
        cout << "\n";
    }


}