#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <string>
#define endl '\n'
//#define int long long

using namespace std;


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    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];
        }
        set<pair<int, int>> d;
        d.insert({0, 0});
        int c = 200;
        for (int i = 0; i < m; ++i) {
            set<pair<int, int>> w;
            for (auto [u, v] : d) {
                int q1 = a[i] - u;
                int w1 = v;
                int q2 = u;
                int w2 = a[i] - v;
                if (q1 >= -c) {
                    w.insert({q1, w1});
                }
                if (w2 >= -c) {
                    w.insert({q2, w2});
                }
            }
            d = w;
        }
        int ans = -2e9;
        for (auto [u, v] : d) {
            ans = max(ans, u + v);
        }
        cout << ans << endl;
    }
    return 0;
}
