#include <bits/stdc++.h>

using namespace std;
using ll = long long;

void solveEq(int n, int m, vector<ll>& x) {
    ll s = x[0] * (min(n, m) - max(m - n, 0) % 2);
    cout << s << '\n';
}

void solveN2(int n, int m, vector<ll>& x) {
    ll ans = 0;
    if (m % 2 == 0) {
        vector<ll> x2(m - 1);
        for (int i = 0; i + 1 < m; ++i) {
            x2[i] = x[i + 1];
        }
        ans += abs(x[0]);
        x = x2;
        --m;
    }
    int i = 0;
    while (i < m) {
        if (i + 1 == m) {
            ans += abs(x[i]);
            break;
        }A
        ans += abs(x[i + 1] - x[i]);
        i += 2;
    }
    cout << ans << '\n';

}

void solvePos(int n, int m, vector<ll>& x) {
    cout << -1 << '\n';
}

void solve() {
    int n, m;
    cin >> n >> m;
    vector<ll> x(m);
    for (int i = 0; i < m; ++i) {
        cin >> x[i];
    }

    if (n == 2) {
        solveN2(n, m, x);
        return;
    }

    bool eq = true;
    for (int i = 0; i < m; ++i) {
        if (x[i] != x[0]) {
            eq = false;
        }
    }
    if (eq) {
        solveEq(n, m, x);
        return;
    }



    bool pos = true;
    for (int i = 0; i < m; ++i) {
        if (x[i] < 0) {
            pos = false;
        }
    }
    if (pos) {
        solvePos(n, m, x);
        return;
    }

    cout << "-1\n";
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    start();
}
