#include <iostream>
//#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
//#include <map>
//#include <cmath>

using namespace std;

typedef long long ll;
//typedef long double ld;

#define int long long
#define ff first
#define ss second
#define endl '\n'
#define all(a) (a).begin, (a).end()

const int INF = 1e18 + 123;

void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> x(m);
    int s = 0;
    for (int i = 0; i < m; ++i) {
        cin >> x[i];
        s += x[i];
    }
    int a = x[0], b = x[0], cnta = 0, cntb = 0;
    for (int i = 0; i < m; ++i) {
        if (x[i] != a) {
            b = x[i];
            cntb++;
        } else {
            cnta++;
        }
    }

    if (a > b) {
        swap(a, b);
        swap(cnta, cntb);
    }

    if (m < n) {
        cout << s << endl;
    } else if (m % 2 == n % 2) {
        int ans = 0;
        for (int k1 = 0; k1 <= n; ++k1) {
            int tans = 0;
            if (k1 % 2 == m % 2) {
                int tk = k1;
                int ka = cnta, kb = cntb;
                for (int i = 0; i < m; ++i) {
                    if (x[i] == b && tk) {
                        tans += b;
                        tk--;
                    } else if (x[i] == a && tk < n) {
                        tans -= a;
                        tk++;
                    } else if (x[i] == b) {
                        tans -= b;
                        tk++;
                    } else if (x[i] == a) {
                        tans += a;
                        tk--;
                    }
                }
                if (tk == 0) {
                    ans = max(ans, tans);
                } 
            }
        }
    }
}
signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int t;
    cin >> t;
    while (t--) {
        solve();
    }
}
