#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
using namespace std;
void test() {
  long long n, k, sum = 0;
  cin >> n >> k;
  deque<long long> v(n), v1(k);
  for (long long i = 0; i < n; i++) cin >> v[i];
  for (long long i = 0; i < k; i++) cin >> v1[i];
  sort(v1.begin(), v1.end());
  sort(v.begin(), v.end());
  while (v1.size() > 0 && v1.front() == 1) {
    sum += 2 * (v.back());
    v.pop_back();
    v1.pop_front();
  }
  reverse(v1.begin(), v1.end());
  if (v1.size() == 0) {
    cout << setprecision(20) << sum << endl;
    return;
  } else {
    while (v1.size() > 0) {
      sum += v.back();
      sum += v.front();
      v.pop_back();
      for (long long i = 0; i < v1.front() - 1; i++) v.pop_front();
      v1.pop_front();
    }
    cout << setprecision(20) << sum << endl;
  }
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  long long t = 1;
  cin >> t;
  while (t--) {
    test();
  }
  return 0;
}
