#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll c = ll(1e6) + 1;

vector<ll> x;
gp_hash_table<ll, ll> mapa;

ll f(ll i, ll k1, ll k2) {
    ll hash = (((((i * c) + k1) % mod) * c) + k2) % mod;
    if (mapa.find(hash) != mapa.end()) return mapa[hash];
    if (i == x.size()) return k1 + k2;
    ll ans = max(f(i + 1, x[i] - k1, k2), f(i + 1, k1, x[i] - k2));
    mapa[hash] = ans;
    return ans;
}

void solve() {
    mapa.clear();
    ll n, m;
    cin >> n >> m;
    x.assign(m, 0);
    for (int i = 0; i < m; i++) cin >> x[i];
    cout << f(0, 0, 0) << "\n";
}

int main() {
#ifdef KABANDJAN
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll t = 1;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
