//#pragma GCC optimize("unroll-loops","Ofast")
//#pragma GCC target("sse","sse2","avx","avx2")
#include <bits/stdc++.h>

//#define int long long
#define F first
#define S second
using namespace std;

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int _;
    cin >> _;
    while (_--) {
        int n, m;
        cin >> n >> m;
        vector<int> a(m);
        for (int i = 0; i < m; ++i) {
            cin >> a[i];
        }
        set<pair<int, int>> mp;
        mp.insert({0, 0});
        for (int i = 0; i < m; ++i) {
            set<pair<int, int>> newmp;
            for (auto [x, y]: mp) {
                newmp.insert({x, a[i] - y});
                newmp.insert({a[i] - x, y});
            }
            swap(mp, newmp);
        }
        int mx = 0;
        for (auto [x, y]: mp) {
            mx = max(mx, x + y);
        }
        cout << mx << '\n';
    }
    return 0;
}
//не забудь сохранять коды!!!