#include <bits/stdc++.h>

#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
template<class T> using ordered_set = tree<T, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update>;

const int mod = int(1e9) + 7, lg = 20;
const ll inf = ll(2e18) + 36;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

struct Fast {
    void main() {
        ll n, m;
        cin >> n >> m;
        vector<ll> x(m);
        for (auto &it: x) cin >> it;
        map <ll, ll> st1, st2, t1, t2;
        st1.insert({0, 0});
        st2.insert({0, 0});
        for (ll i = 0; i < m; i++) {
            t1.clear();
            t2.clear();
            for (auto& [f, s] : st1) {
                if (!t1.count(x[i] - f)) {
                    t1[x[i] - f] = s;
                } else {
                    t1[x[i] - f] = min(t1[x[i] - f], s);
                }
                if (!t1.count(f)) {
                    t1[f] = x[i] - s;
                } else {
                    t1[f] = min(t1[f], x[i] - s);
                }


                if (!t2.count(x[i] - f)) {
                    t2[x[i] - f] = s;
                } else {
                    t2[x[i] - f] = max(t2[x[i] - f], s);
                }
                if (!t2.count(f)) {
                    t2[f] = x[i] - s;
                } else {
                    t2[f] = max(t2[f], x[i] - s);
                }
            }
            for (auto& [f, s] : st2) {
                if (!t1.count(x[i] - f)) {
                    t1[x[i] - f] = s;
                } else {
                    t1[x[i] - f] = min(t1[x[i] - f], s);
                }
                if (!t1.count(f)) {
                    t1[f] = x[i] - s;
                } else {
                    t1[f] = min(t1[f], x[i] - s);
                }


                if (!t2.count(x[i] - f)) {
                    t2[x[i] - f] = s;
                } else {
                    t2[x[i] - f] = max(t2[x[i] - f], s);
                }
                if (!t2.count(f)) {
                    t2[f] = x[i] - s;
                } else {
                    t2[f] = max(t2[f], x[i] - s);
                }
            }
            st1 = t1;
            st2 = t2;
        }
        ll ans = -inf;
        for (auto& [f, s] : st2) {
            ans = max(ans, f + s);
        }
        cout << ans;
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    ll testC; cin >> testC;
    while (testC--) {
        Fast().main();
        cout << '\n';
    }
    return 0;
}
