#include <bits/stdc++.h>
using namespace std;
#define int long long
const long long INF = 1e18, MOD = 1e9 + 7;

void solve();

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin >> t;
    while (t--){
        int n, m;
        cin >> n >> m;
        vector <int> a(m);
        for (int i = 0; i < m; i++){
            cin >> a[i];
        }
        map <int, pair <int, int>> sl;
        sl[0] = {0, 0};
        for (int i = 0; i < m; i++){
            map <int, pair <int, int>> sl1;
            for (auto x : sl){
                if (sl1.find(a[i] - x.first) == sl1.end()){
                    sl1[a[i] - x.first] = x.second;
                }
                else{
                    sl1[a[i] - x.first] = {max(x.second.first, sl1[a[i] - x.first].first), min(x.second.second, sl1[a[i] - x.first].second)};
                }
                if (sl1.find(x.first) == sl1.end()){
                    sl1[x.first] = {a[i] - x.second.second, a[i] - x.second.first};
                }
                else{
                    sl1[x.first] = {max(a[i] - x.second.second, sl1[x.first].first), min(a[i] - x.second.first, sl1[x.first].second)};
                }
            }
            sl = sl1;
        }
        int ans = -INF;
        for (auto x : sl){
            ans = max(ans, x.first + x.second.first);
            ans = max(ans, x.first + x.second.second);
        }
        cout << ans << "\n";
    }
}
