#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

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

void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> x(m);
    for (int i = 0; i < m; ++i) {
        cin >> x[i];
    }
    bool eq = true;
    for (int i = 0; i < m; ++i) {
        if (x[i] != x[0]) {
            eq = false;
        }
    }
    if (eq) {
        solveEq(n, m, x);
    }
    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();
}
