#include <bits/stdc++.h>
#define int long long

using namespace std;

const int inf = 2e18;

void solve() {
    int n, m; cin >> n >> m;
    vector<int> x(m);
    for (int i = 0; i < m; ++i) {
        cin >> x[i];
    }
    int k = min(n, m);
    int ans = x[0] * (k - 2 * ((n - k) % 2));
    cout << ans << '\n';
}

signed main(void) {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n; cin >> n;
    for (int i = 0; i < n; ++i) {
        solve();
    }
}