#include <bits/stdc++.h>
#define int long long

using namespace std;

signed main() {
    int t;
    cin >> t;
    while (t--) {
        int n, m;
        cin >> n >> m;
        vector <int> x(m);
        for (int i = 0; i < m; ++i) {
            cin >> x[i];
        }
        set <pair <int, int>> s;
        s.insert({0, 0});
        for (int i = 0; i < m; ++i) {
            set <pair <int, int>> s1;
            for (auto p1 : s) {
                auto p = p1;
                p.first = x[i] - p.first;
                if (p.first > p.second) {
                    swap(p.first, p.second);
                }
                s1.insert(p);
            }
            for (auto p1 : s) {
                auto p = p1;
                swap(p.first, p.second);
                p.first = x[i] - p.first;
                if (p.first > p.second) {
                    swap(p.first, p.second);
                }
                s1.insert(p);
            }
            s = s1;
        }
        int ans = -1e9;
        for (auto p : s) {
            ans = max(ans, p.first + p.second);
        }
        cout << ans << endl;
    }
    return 0;
}
