#include <bits/stdc++.h>

using ll = long long;

using namespace std;

#define int ll

const int INF = LLONG_MAX / 2;

void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> x(m);
    int mx = -INF, mn = +INF;
    for (int i = 0; i < m; i++) {
        cin >> x[m - i - 1];
        mx = max(mx, x[m - i - 1]);
        mn = min(mn, x[m - i - 1]);
    }
    int curb = n;
    int cursum = 0;
    for (int i = 0; i < m; i++) {
        if (curb + 2 > n) {
            curb -= 2;
            cursum += x[i];
        } else if (curb - 2 < -n) {
            curb += 2;
            cursum -= x[i];
        } else {
            if (curb + 2 <= n && x[i] == mn) {
                curb += 2;
                cursum -= x[i];
            } else if (curb - 2 >= -n && x[i] == mx) {
                curb -= 2;
                cursum += x[i];
            } else {
                exit(1);
            }
        }
    }
    cout << cursum << "\n";
}

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

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

    cout << "\n";
    return 0;
}