#include <bits/stdc++.h>

using namespace std;

const long long INF = 1e18;

int main()
{
    int t; cin >> t;
    for (int ti = 0; ti < t; ++ti){
        int n, m; cin >> n >> m;
        vector<long long> a(m);
        for (int i = 0; i < m; ++i)
            cin >> a[i];

        long long ans = 0;
        for (int i = 0; i < (1 << m); ++i){
            bitset<20> mask(i);
            int cnt = 0;
            long long temp = 0;
            bool ok = true;
            for (int j = m - 1; j >= 0; --j){
                if (mask[j]){
                    ++cnt;
                    temp += a[j];
                }
                else{
                    --cnt;
                    temp -= a[j];
                }
                if (cnt < 0 || cnt > n){
                    ok = false;
                    break;
                }
            }
            if (ok)
                ans = max(ans, temp);
        }

        cout << ans << endl;
    }

    return 0;
}
