// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

mt19937 rnd(69); // chrono::steady_clock::now().time_since_epoch().count()
#define all(x) x.begin(), x.end()
#define int long long
#define ull unsigned long long
#define ld long double
#pragma GCC optimize("O3,unroll-loops")
// #pragma GCC target("avx2")

const long long INF = 1e15 + 69;
const int MAXN = 2e5 + 11;

void solve() {
    int n, m, sum;
    cin >> n >> m;
    sum = 0;
    vector<int> x(m);
    multiset<int> cur_last;
    cur_last.clear();
    sum = 0;
    for (int i = 0; i < m; i++) {
        cin >> x[i];
        sum += x[i];
    }
    if (n == 1) {
        sum = 0;
        for (int i = 0; i < m; i++) {
            sum = x[i] - sum;
        }
        cout << sum << endl;
        return;
    }
    int ans = -INF;
    if (false) {
        for (int mask = 0; mask < (1 << m); mask++) {
            pair<int, int> cur_ans = {0, 0};
            for (int i = 0; i < m; i++) {
                if ((mask >> i) & 1) {
                    cur_ans.second = x[i] - cur_ans.second;
                } else {
                    cur_ans.first = x[i] - cur_ans.first;
                }
            }
            ans = max(ans, cur_ans.first + cur_ans.second);
        }
        cout << ans << endl;
    } else {
        int ans1 = -INF;
        int ans2 = -INF;
        int ans3 = -INF;
        for (int mask = 0; mask < (1 << (m / 2)); mask++) {
            pair<int, int> cur_ans = {0, 0};
            for (int i = 0; i < m / 2; i++) {
                if ((mask >> i) & 1) {
                    cur_ans.second = x[i] - cur_ans.second;
                } else {
                    cur_ans.first = x[i] - cur_ans.first;
                }
            }
            ans1 = max(ans1, -cur_ans.first - cur_ans.second);
            ans2 = max(ans2, cur_ans.first + cur_ans.second);
            ans3 = max(ans3, cur_ans.first - cur_ans.second);
            ans3 = max(ans3, cur_ans.second - cur_ans.first);
        }
        for (int mask2 = 0; mask2 < (1 << (m - (m / 2))); mask2++) {
            pair<int, int> cur_ans = {0, 0};
            bool parity1 = true;
            bool parity2 = true;
            for (int i = m / 2; i < m; i++) {
                if ((mask2 >> (i - m / 2)) & 1) {
                    cur_ans.second = x[i] - cur_ans.second;
                    parity1 = !parity1;
                } else {
                    cur_ans.first = x[i] - cur_ans.first;
                    parity2 = !parity2;
                }
            }
            if (!parity1 && !parity2) {
                ans = max(ans, cur_ans.first + cur_ans.second + ans1);
            } else {
                if (parity1 && parity2) {
                    ans = max(ans, cur_ans.first + cur_ans.second + ans2);
                } else {
                    ans = max(ans, cur_ans.first + cur_ans.second + ans3);
                }
            }
        }
        cout << ans << endl;
    }
}

signed main()
{
    ios_base::sync_with_stdio(false);
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
