#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = long double;
#define int long long
#define MULTY
constexpr int INF = 1e18;
constexpr int MOD = 1e9 + 7;
//mt19937_64 rnd(0);

void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> x(m);
    for (int i = 0; i < m; ++i) {
        cin >> x[i];
    }
    set<pair<int, int>> st1, st2;
    st1.insert({0, 0});
    for (int i = 0; i < m; ++i) {
        for (auto el : st1) {
            st2.insert({x[i] - el.first, el.second});
            st2.insert({el.first, x[i] - el.second});
        }
        st1 = st2;
        st2.clear();
    }
    int ans = 0;
    for (auto el : st1) {
        ans = max(ans, el.first + el.second);
    }
    cout << ans << "\n";
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
#ifdef MULTY
    cin >> t;
#endif
    while (t--) {
        solve();
    }

    return 0;
}