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

using namespace std;
using ll = long long;
using ld = long double;
const int INF = 1e18;
const int MOD = 1e9 + 7;
const int N = 3e5 + 69;

void solve() {
    int n, m, x;
    cin >> n >> m;
    for (int i = 0; i < m; ++i) cin >> x;
    int ans = min(m, n - 1) * x;
    m -= min(m, n - 1);
    if (m % 2 == 0) {
        cout << ans;
    } else {
        cout << ans + x;
    }
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t;
    cin >> t;
    while (t--) {
        solve();
        cout << "\n";
    }
    return 0;
}
