#include <bits/stdc++.h>

//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx2")

#define int long long

using ll = long long;
using namespace std;

void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> a(m);
    for (int i = 0; i < m; i++) {
        cin >> a[i];
    }
    if (m < n) {
        cout << m * a[0] << "\n";
        return;
    } else {
        if ((m - n) % 2) {
            cout << (m - 1) * a[0] << "\n";
        } else {
            cout << m * a[0] << "\n";
        }
    }
}

signed main() {
    int t = 1;
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
//    cin >> t;
#else
    ios_base::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
#endif
    cin >> t;
    while (t--) {
        solve();
    }
}
