#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) x.begin(), x.end()
#define siz(x) int(x.size())
#define ceil(a, b) (((a) + (b) - 1) / (b))
const int INF = 2e9 + 7;
const ll LINF = 1e18 + 7;

void solve() {
    int n, m;
    cin >> n >> m;
    vector<ll> x(m);
    for(int i = 0; i < m; ++i) cin >> x[i];
    int km = (m - n + 1) / 2;
    cout << x[0] * (n - 1) + (m - n + 1 - km) * x[0] - km * x[0];
}
int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    cout << fixed; cout.precision(8);
#ifdef INEYOK
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t;
    cin >> t;
    while(t--) {
        solve();
    }
}
