#include <bits/stdc++.h>
using namespace std;
#define int long long
void solve() {
    int k, n;
    cin >> k >> n;
    vector <int> a(n);
    for (int& x : a)
        cin >> x;
    bool g = true;
    for (int i = 0; i < n - 1; i++) {
        if (a[i] != a[i + 1])
            g = false;
    }
    if (g) {
        cout << (n - (n - k + 1) / 2) * a[0] << endl;
        return;
    }
    if (k == 1) {
        int s = 0, f = 1;
        if (n % 2 == 0) f = -1;
        for (int i = 0; i < n; i++) {
            s += a[i] * f;
            f *= -1;
        }
        cout << s << endl;
        return;
    }
    if (k == 2) {
        vector <int> b(n - 1);
        int s = 0, s1 = 0;
        for (int i = 0; i < n; i++) {
            if (i != n - 1) b[i] = a[i];
            s += a[i];
        }
        sort(b.begin(), b.end());
        int kol = (n + 1) / 2 - 1;
        for (int i = 0; i < kol; i++) s1 += b[i];
        cout << s - s1 * 2 << endl;
        return;
    }
}
signed main() {
    int t = 1;
    cin >> t;
    while (t--) {
        solve();
    }
}
