// semenInRussia 2025
#include <cstdint>
#include <iostream>
#include <vector>
using namespace std;

void solve() {
  int n, m;
  cin >> n >> m;
  vector<int> x(m);

  for (auto &v : x) {
    cin >> v;
  }

  int64_t ans = 1ll * min(n, m) * x[0];
  m -= min(n, m);
  if (m & 1) {
    ans -= x[0];
  }

  cout << ans << endl;
}

int main() {
  int tt;
  cin >> tt;
  while (tt--) {
    solve();
  }
}